我想用mshflexgrid删除某一行并同时删除数据库中那一行,为什么总是显示参数类型不匹配,或不在可以接受的范围内,或与其他参数冲突
Private Sub Command2_Click()'连接数据库
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
'删除
Dim sql As String, r$
Set rs = New ADODB.Recordset '创建数据集对象的连接
sql = "delete from [设计计算] where [管段编号]=' " & MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 0) & " ' " '删除指定行
conn.Execute sql '执行sql语句
MSHFlexGrid1.RemoveItem MSHFlexGrid1.Row
rs.Open sql, conn, adOpenKeyset, adLockBatchOptimistic
MsgBox "删除成功!"
'删除数据库中该行记录
Dim a As String
a = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 0)
'锁定到这条记录,然后查询并删除
txtSQL = "select * from [设计计算] where [管段编号]= '" & a & "'"
Set rs = conn.ExecuteSQL(txtSQL, msgtext) 这行显示参数类型不匹配,或不在可以接受的范围内,或与其他参数冲突
conn.Close '关闭连接
Set conn = Nothing '释放变量
End Sub