text1.text为access表中的自动编号类型,但是运行时显示类型不符
Private Sub Command2_Click()
Set con = New ADODB.Connection
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\swdata.mdb;Persist Security Info=False "
con.CursorLocation = adUseClient
con.Open
rst.Open "select * from usermgmt where usermgmt!id= ' " & CLng(Text1.Text) & " ' ", con, adOpenKeyset, adLockOptimistic
If rst.BOF = True Or rst.EOF Then
MsgBox "您输入的用户不存在! ", 48, "警告 "
Else:
rst.Delete
Unload Me
End If
End Sub
id在access为自动编号类型
为什么与clng(text1.text)类型不符?
[解决办法]
试试cint
[解决办法]
rst.Open "select * from usermgmt where usermgmt!id= ' " & Text1.Text & " ' ", con
[解决办法]
不要用 ' "& text1.text & " ' ,試試用 "& text1.text & " ,我最近遇到過,這樣就解決了。
[解决办法]
rst.Open "select * from usermgmt where usermgmt.id= " & Text1.Text & " ", con, adOpenKeyset, adLockOptimistic
'usermgmt!id --> usermgmt.id
[解决办法]
temp = Val(delete1.Text)
delete0.Open "delete from salerecord where uid= " & temp & " ", Con, adOpenDynamic, adLockOptimistic