Hey,
I am trying to connect to a MSSQL database but i keep getting the error "Compile error: User-defined type not defined". My code is below:
Anyone have aly ideas??? thanks alot!!!
I am trying to connect to a MSSQL database but i keep getting the error "Compile error: User-defined type not defined". My code is below:
Code:
Option Explicit
Private Sub Text1_Change()
Dim cnCon As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strSQL As String
Set cnCon = New ADODB.Connection
Set rsProbe = New ADODB.Recordset
strSQL = "SELECT blah blah blah"
With cnCon
.Provider = "SQLOLEDB"
.Properties("Data Source") = "your sql server"
.Properties("User ID") = "your user id"
.Properties("Password") = "your password"
.Open
.DefaultDatabase = "your default database"
End With
With rs
.ActiveConnection = cnCon
.CursorType = adOpenStatic
.CursorLocation = adUseServer
.LockType = adLockOptimistic
.Source = strSQL
.Open
End With
MsgBox Text1.Text
End Sub
Anyone have aly ideas??? thanks alot!!!
Comment