为什么总是在Set mrc = ExecuteSQL(txtsql, msgtext)处报错子程序或函数未定义
急急急!!!我想用mshflexgrid删除某一行,怎么同时删除mshflexgrid和数据库的内容呢??为什么总是在Set mrc = ExecuteSQL(txtsql, msgtext)处报错子程序或函数未定义??Private Sub Command2_Click()
Dim txtsql As String '定义一个字符串,存放sql的语句
Dim msgtext As ADODB.Recordset '定义一个字符串,存放连接数据库的结果。一般不再用户界面体现
''连接数据库
'If conn.State = 0 Then
' conn.ConnectionString = "Provider=Microsoft.jet.OLEDB.4.0;Data Source=" & _
' App.Path & "\设计计算.mdb;Persist Security Info=False" '连接数据库的驱动字符串并打开数据库
' conn.Open
'End If
'删除mshflexgrid
Dim sql As String
Set rs = New ADODB.Recordset '创建数据集对象的连接
sql = "delete from [设计计算] where [管段编号]=' " & MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 0) & " ' " '删除指定行
conn.Execute sql '执行sql语句
MSHFlexGrid1.RemoveItem MSHFlexGrid1.Row
'删除数据库
txtsql = "select * from [设计计算] where [管段编号] = '" & MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 0) & "'"
Set conn = ExecuteSQL(txtsql, msgtext)
'rs.Open sql, conn, adOpenKeyset, adLockBatchOptimistic
MsgBox "删除成功!"
conn.Close '关闭连接
Set conn = Nothing '释放变量
End Sub