After reading many of the articles in this forum I attempted to create an ADO connection to a database attached to MSDE2000A.
I am using VB6 and have referenced ADO 2.8 library.
The using the SQLOLEDB.1 provider, the connection opens but when I actually execute the line:
.Open sSQL, Con, adOpenStatic, adLockBatchOptimistic, adCmdText
I get an invalid Object Name "Employee".
I have also created a DSN connection via ODBC and using the MSDASQL.1 provider the connection opens and I can read the records. When I set up the DSN connection I also use NT authentication which I am sure is similar to SSPI.
The code used follows and includes the 2 connection strings that I use:
Can anyone offer some advice please.
Option Explicit
Dim Con As ADODB.Connection
Dim Rec As ADODB.Recordset
Dim sConn As String
Dim sSQL As String
Private Sub btnRecords_Click()
Set Con = New ADODB.Connection
Con.ConnectionString = "Provider=SQLOLEDB.1;" & _
"Persist Security Info=False;" & _
"Data Source=(Local);" & _
"Initial Catalogue=RMJR Personnel Management System;" & _
"Integrated Security=SSPI"
'Con.ConnectionString = "Provider=MSDASQL.1;" & _
"Persist Security Info=False;" & _
"Data Source=RMJR Personnel Management System;" & _
"Initial Catalog=RMJR Personnel Management System"
Con.Open
Debug.Print Con
sSQL = "SELECT * FROM Employee"
Set Rec = New ADODB.Recordset
If Con.State = adStateOpen Then
With Rec
.CursorLocation = adUseClient
.Open sSQL, Con, adOpenStatic, adLockBatchOptimistic, adCmdText
MsgBox Rec.RecordCount
Set Rec = Nothing
End With
Else
Con.Close
MsgBox "The database connection failed!", , "Connection Failure"
End If
Con.Close
Set Con = Nothing
End Sub
I am using VB6 and have referenced ADO 2.8 library.
The using the SQLOLEDB.1 provider, the connection opens but when I actually execute the line:
.Open sSQL, Con, adOpenStatic, adLockBatchOptimistic, adCmdText
I get an invalid Object Name "Employee".
I have also created a DSN connection via ODBC and using the MSDASQL.1 provider the connection opens and I can read the records. When I set up the DSN connection I also use NT authentication which I am sure is similar to SSPI.
The code used follows and includes the 2 connection strings that I use:
Can anyone offer some advice please.
Option Explicit
Dim Con As ADODB.Connection
Dim Rec As ADODB.Recordset
Dim sConn As String
Dim sSQL As String
Private Sub btnRecords_Click()
Set Con = New ADODB.Connection
Con.ConnectionString = "Provider=SQLOLEDB.1;" & _
"Persist Security Info=False;" & _
"Data Source=(Local);" & _
"Initial Catalogue=RMJR Personnel Management System;" & _
"Integrated Security=SSPI"
'Con.ConnectionString = "Provider=MSDASQL.1;" & _
"Persist Security Info=False;" & _
"Data Source=RMJR Personnel Management System;" & _
"Initial Catalog=RMJR Personnel Management System"
Con.Open
Debug.Print Con
sSQL = "SELECT * FROM Employee"
Set Rec = New ADODB.Recordset
If Con.State = adStateOpen Then
With Rec
.CursorLocation = adUseClient
.Open sSQL, Con, adOpenStatic, adLockBatchOptimistic, adCmdText
MsgBox Rec.RecordCount
Set Rec = Nothing
End With
Else
Con.Close
MsgBox "The database connection failed!", , "Connection Failure"
End If
Con.Close
Set Con = Nothing
End Sub