Discussion Locked

Server has not been opened message in VB

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I am writing an app in VB 6.0 and Crystal 8.0. The report is using a database on a SQL server 7.0 system. In Crystal everything runs fine, however in VB, I can't seem to get the syntax to open the connection to the server. I have to pass the server name, userid, password, and database to be able to view the report in the Crystal Preview form. Please help.
Cathy

6 replies

by madestroitsolutions

Your explanation is not enough to figure out an answer. Send me the code and what you are trying to do explained by e-mail to juanja01@optonline.net and I will be glad to help you.

Good Luck

by miss kitty

Here's my code:
frmMain:
Option Explicit
Public crxApplication As New Application
Public CrystalReport As CRAXDRT.Report

Private strDatabase As String

Private Sub cmdCS_Click()
Dim x As Integer
Dim crxParameters As CRAXDRT.ParameterFieldDefinitions
Dim Cn As New ADODB.Connection
Dim crxParameter As CRAXDRT.ParameterFieldDefinition

frmGetParameters.Show vbModal

Set CrystalReport = crxApplication.OpenReport("E:\PltERA\Crystal Reports\Check VoucherReports\CSchkvouch.rpt", 1)

Set crxParameters = frmMain.CrystalReport.ParameterFields
For x = 1 To crxParameters.Count
Set crxParameter = crxParameters.Item(x)
If crxParameter.Name = "{?@Begin}" Then
crxParameter.AddCurrentValue frmGetParameters.strBegin
End If
If crxParameter.Name = "{?@End }" Then
crxParameter.AddCurrentValue frmGetParameters.strEnd
End If
Next x

Cn.ConnectionTimeout = 100
Cn.Open ("Provider=MSDASQL.1;Password=sa;Persist Security Info=True;User ID=sa;Data Source=CONSUMERS_2;Mode=Read;Initial Catalog=Plt_CS")
'"Driver={SQL Server};Server=consumers_2;Uid=sa;Pwd=sa;Database=consumers_2"
frmCSViewer.Show vbModal
Cn.Close
End Sub
on frmCSViewer:
Option Explicit

Private Sub Form_Load()
CRViewer1.ReportSource = frmMain.CrystalReport
CRViewer1.ViewReport
Screen.MousePointer = vbDefault

End Sub

Private Sub Form_Resize()
CRViewer1.Top = 0
CRViewer1.Left = 0
CRViewer1.Height = ScaleHeight
CRViewer1.Width = ScaleWidth

End Sub

This discussion is closed to new replies.