Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems connecting to SQL with VB

Status
Not open for further replies.

DeanHall

Programmer
Jan 3, 2001
3
0
0
GB

Hi I am having problems connecting to a SQL database using VB 6.0 and the RDC.
The code below connects me to the database CCX_GMSM using the ADO connection method when I have no database selected in the report. But when I select the same database
via the ADO connection in the report and add a field to the detail section of the report and then run the application I get the error message "Server has not yet been opened".

Can anyone tell me what Im doing wrong.

TIA Dean







Dim m_Report As New CrystalReport1

Dim cnn1 As ADODB.Connection
Dim datcmd1 As ADODB.Command

Private Sub Command1_Click()
Dim fld As FieldObject
Dim strCnn As String

Set cnn1 = New ADODB.Connection
strCnn = "Provider=MSDASQL;Persist Security info=True";Data Source=CCX_GMSM;Mode=Read"
cnn1.Open strCnn, "gmadmin", "gmadmin"
 
I've recently had similar problems with connecting to SQL server databases through Delphi code - the way I eventually had success was by setting the 'LogOnInfo' for each of the tables and also setting the location appropriately - i.e. 'DATABASE-NAME.dbo.TABLE-NAME'.
I'm not sure if this will prove helpful at all ... ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top