Public Sub sqlext(ByVal strsqlstmt As String) '执行数据库操作 Dim cmd As New ADODB.Command connect Set cmd.ActiveConnection = cnn cmd.CommandText = strsqlstmt cmd.Execute Set cmd = Nothing disconnect End Sub Public Function queryext(ByVal strsqlstmt As String) As ADODB.Recordset '执行数据库查询 Dim rst As New ADODB.Recordset connect Set rst.ActiveConnection = cnn rst.CursorType = adOpenDynamic rst.LockType = adLockOptimistic rst.Open strsqlstmt Set queryext = rst End Function
麻烦各位了你最起码得把变量strsqlstmt 的值给出来,才能帮你看什么原因。。。 没带参数吧!。。。。。。。。。。。。。。。。。。。。。。。 这段代码我是根据书上的 rst.open strsqlstmt上面只写着打开记录集 只知道ByVal strsqlstmt As String 而且strsqlstmt只出现在Public Sub sqlext(ByVal strsqlstmt As String)和Public Function queryext(ByVal strsqlstmt As String) As ADODB.Recordset这两个里面 那该如何定义strsqlstmt变量 试试
Private Sub Command1_Click() Dim MyString() As String Open "a.xml" For Binary As #1 ' 打开刚创建的文件。 ReDim MyString(LOF(1) - 1) Put #1, , MyRecord ' 读入所有字符到变量中 ......