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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO Connection String

Status
Not open for further replies.

PADFOR

Programmer
Feb 5, 2001
25
GB
I am trying to implement a three tier client/server database using VB, and SQL Server.

I am having trouble with the connection string in my data services tier. The code can be seen below:

Private Sub Class_Initialize()
'Create the Recordsets

On Error GoTo HandleError
Set conParthus = New ADODB.Connection
Set rsBUDept = New ADODB.Recordset
Set rsOffice = New ADODB.Recordset

'Open the Connection
conParthus.ConnectionString = "driver={SQL Server};" & _
"server=W98SYSREC;uid=;pwd=;database=Parthus;Trusted_Connection=Yes;"
conParthus.Open
Debug.Print "Connection1 successful"

'Open the rsBUDept Recordset
With rsBUDept
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.Open "Select * from BUDepts", conParthus, , , adCmdText
End With

'Open the rsOffice Recordset
With rsOffice
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.Open "Select OfficeID, OfficeName from Office", _
conParthus, , , adCmdText
End With

'Add Recordsets to the DataMembers collection
With DataMembers
.Add "BUDept"
.Add "Office"
End With

Class_Initialize_Exit:
Exit Sub

HandleError:
Err.Raise dsOperationFailed, "DBBUDept", "Recordset open failure"
End Sub

Every time I run the program, it reports the following:

Run-time error '-2147220990 (80040202)':

Recordset open failure

If anyone can help, I would appreciate it.
 
Hello,

First, remove your error handling. Get rid of the Err.Raise. This masks your underlying error. So until you figure out exactly what is wrong, raise the original error. If you must raise use the following:

Err.Raise Err.Number, Err.Source, Err.Description.

Connection String:

I am assuming that you are trying to connect using a DSN-less connection string. I have been able to connect to a SQL Server DB using the following connection string.

Provider=MSDASQL;Persist Security Info=False;Data Source=Thorin;UID=yourUID;PWD=yourPWD

In His Love
scott
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top