ADODB connection

veriajeth

New member
Local time
Today, 15:06
Joined
Jul 11, 2011
Messages
5
Hi everyone,

I have used the below code in Access2003 and it works fine. Now I tried the same in Access2007 by creating a new project but I get an error "user-defined type not defined" in line 4.

Is there anything I have to do first before coding this?


Private Sub Command0_Click()
On Error GoTo Err_Command0_Click
Const conObjStateClosed = 0
Dim dstUsers As ADODB.Recordset
Dim dstMembers As ADODB.Recordset
Dim cnn As ADODB.Connection

Dim xCurrentUser As String
Dim xPassword As String

xCurrentUser = "veriajeth"
xPassword = "12345"

Set cnn = New ADODB.Connection
cnn.Open "Provider=SQLOLEDB.1;" & _
"Server=192.168.0.237;Initial Catalog=NNetSales", xCurrentUser, xPassword


Set dstUsers = New ADODB.Recordset
dstUsers.ActiveConnection = cnn
dstUsers.CursorType = adOpenKeyset
dstUsers.LockType = adLockOptimistic
dstUsers.Open "Select * From Employee", , , , adCmdText


dstUsers.MoveFirst
MsgBox dstUsers("EmployeeName")


dstUsers.Close
Set dstUsers = Nothing

Exit_Command0_Click:
Exit Sub

Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click

End Sub

_________
Thanks.
 
Check references to ADO

Code window->Tools->References
 
Check references to ADO

Code window->Tools->References


Yes, I've checked that, but found nothing.

Why it work in 2003 and not in 2007?
 
"found nothing" means what? NO references to ADO or NO references at all? A2007 is a bit more picky about things
 
Yes, I've checked that, but found nothing.

Why it work in 2003 and not in 2007?
What do you mean you found nothing? What ADO reference is currently checked? And are you on Windows 7 SP1?
 

Users who are viewing this thread

Back
Top Bottom