[求助]请教一个有关变量定义的问题
在VB的一个窗体里用到了Option Explicit语句然后有一个按钮,代码如下:
Private Sub addnew_Click()
Dim sdbname As String, str As String, Dirs As String, k As String, t As String
Dim conn As Connection
Dim rs As Recordset
Set conn = New Connection
Set rs = New Recordset
sdbname = "F:\QQ.mdb"
str = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Persist Security Info=False;" & "Data Source=" & sdbname & ";" & "Jet OLEDB:Database Password="";"
conn.Open str
rs.Open "Select * from alluser", conn, 1, 3, 1
rs.AddNew
rs("name").Value = "1212"
rs.Update
rs.Close
conn.Close
End Sub
运行时出现错误提示:无效使用关键字 New
后来我将
Set conn = New Connection
Set rs = New Recordset
改成
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
出现的错误提示是:未找到方法或数据成员
conn.Open str 这一句被标记为错误行
请问该怎么去改正代码?
感激不尽!
[此贴子已经被作者于2005-3-26 6:08:53编辑过]