我在asp下可以自由使用adodb来连接数据库,可是在vb6,0下不能使用了。我也明白格式不同,写程序的时候也注意格式了,与书上无疑(为了测试为什么不可以用),结果,还是不行。特请教问题,是这样的,部分程序放出,
(mydb是我的odbc数据源,测试连接是可以的,数据库是sql server 2000)
Dim conn As Adodb.Connection
Dim rs As Adodb.Recordset
Set conn = New Adodb.Connection
conn.Open "mydb", "", ""
Dim sqlstr As String
sqlstr = "select * from user_db_tab where username='" & name & "'"
Set rs = server.CreateObject("adodb.recordset")
rs.Open sqlstr, conn, 1, 1
其错误提示是----编译错误:用户定义类型未定义,
然后指示的错误是 conn As Adodb.Connection。
我在线等待请回答。谢谢
(mydb是我的odbc数据源,测试连接是可以的,数据库是sql server 2000)
Dim conn As Adodb.Connection
Dim rs As Adodb.Recordset
Set conn = New Adodb.Connection
conn.Open "mydb", "", ""
Dim sqlstr As String
sqlstr = "select * from user_db_tab where username='" & name & "'"
Set rs = server.CreateObject("adodb.recordset")
rs.Open sqlstr, conn, 1, 1
其错误提示是----编译错误:用户定义类型未定义,
然后指示的错误是 conn As Adodb.Connection。
我在线等待请回答。谢谢
Dim rs As Adodb.Recordset
Set conn = New Adodb.Connection
conn.Open mydb
Dim sqlstr As String
sqlstr = "select * from user_db_tab where username='" & name & "'"
rs.Open "", conn, adOpenDynamic, adLockBatchOptimistic
还是在 conn as adodb.connection
“工程”-->“引用”-->“Microsoft AxtiveX Data Objects 2.X Library”
注:2.X为版本号,如果你机子上有高版本的就用高版本的,如:2.5或2.6的
然后:
Dim conn As Adodb.Connection
Dim rs As Adodb.Recordset
Set conn = New Adodb.Connection
conn.Open "mydb", "", ""
Dim sqlstr As String
sqlstr = "select * from user_db_tab where username='" & name & "'"
Set rs =new adodb.recordset
rs.cursorlocation=aduseclient
rs.Open sqlstr, conn, 1, 1