编译错误:未找到方法或数据成员
我在模里面已经定义了数据库链接
Public Function ExecuteSQL(ByVal SQL As String, MsgString As String) As ADODB.Recordset
'传递参数SQL传递查询语句,MsgString传递查询信息
'自身以一个数据对象的形式返回
Dim cnn As ADODB.Connection
'定义连接
Dim rst As ADODB.Recordset
'定义字符串
Dim sToKens() As String
'异常处理
On Error GoTo ExecuteSQL_Error
'用split函数产生一个包含各个子串的数组
sToKens = Split(SQL)
'创建连接
Set cnn = New ADODB.Connection
'打开连接
cnn.Open ConnectString
'判断字符串中是否含有指定内容
'IF.................................................................
If InStr( "insert,delete,update ", UCase$(sToKens(0))) Then
'执行查询语句
cnn.Execute SQL
'返回查询结果
MsgString = sToKens(0) & " query successful "
Else
'创建数据库对象
Set rst = New ADODB.Recordset
'返回查询结果
rst.Open Trim$(SQL), cnn, adOpenKeyset, adLockOptimistic
'rst.MoveLast 'get RecordCount
'返回记录集对象
Set ExecuteSQL = rst
MsgString = " 查询到 " & rst.RecordCount & "条记录 "
End If
'End If............................................................
ExecuteSQL_Exit:
Set rst = Nothing
Set cnn = Nothing
Exit Function
ExecuteSQL_Error:
MsgString = "查询错误 " & Err.Description
Resume ExecuteSQL_Exit
End Function
Public Function ConnectString() As String
'返回一个数据库连接
'ConnectString = "FileDSN=library.dsn;UID=sa;PWD=sql "
'ConnectString = "Provider=MSDASQL.1;Persist Security Info=False;User ID=sa;Data Source=library "
ConnectString = "DSN=library;UID=sa;PWD=sql;APP=Visual Basic;WSID=FKGL-PGTX0FPQWE;DATABASE=library "
End Function
其中
Private Sub M_ChgReaderType_Click()
Dim intCount As Integer
'判断是否打开记录窗体
If flagRTedit Then
If frmReadertype.msgList.Row > 1 Then
'设置为修改状态
gintRTmode = 1
intCount = frmReadertype.msgList.Row
frmReadertype1.txtSQL = "select * from readertype where typeno= " & Trim(frmReadertype.msgList.TextMatrix(intCount, 1)) & " "
frmReadertype.Show
Else
Call menuaddreadertype_click
End If
frmReadertype.txtSQL = "select * from readertype "
frmReadertype.Show
End If
End Sub
其中frmReadertype1.txtSQL中,.txtsql用蓝色标出。
[解决办法]
你调试一下,看问题出在哪里?
[解决办法]
看下你的frmReadertype1窗體中是否有txtSQL這個控件或自定義屬性
[解决办法]
frmReadertype1.txtSQL = "select * from readertype where typeno= " & Trim(frmReadertype.msgList.TextMatrix(intCount, 1)) & " "