vb运行这个界面时老是出现标准表达式中数据类型不匹配,求解??
PrivateSubForm_Load()Dimmilnk$mpath=App.PathIfRight(mapth,1)<>"\"Thenmpath=mpath+"\"m...
Private Sub Form_Load()
Dim milnk$
mpath = App.Path
If Right(mapth, 1) <> "\" Then mpath = mpath + "\"
mlink = "Provider= Microsoft.Jet.OLEDB.4.0;Data Source =" + mpath + "图书馆.mdb"
Adodc1.ConnectionString = mlink
Adodc1.CommandType = adCmdUnknown
Adodc1.RecordSource = "select * from 图书借还表 "
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
End Sub
Private Sub Command4_Click()
Adodc1.CommandType = adCmdUnknown
Adodc1.RecordSource = "select * from 图书借还表 where 读者编号='" & Val(Text1) & "'"
Adodc1.Refresh
End Sub 展开
Dim milnk$
mpath = App.Path
If Right(mapth, 1) <> "\" Then mpath = mpath + "\"
mlink = "Provider= Microsoft.Jet.OLEDB.4.0;Data Source =" + mpath + "图书馆.mdb"
Adodc1.ConnectionString = mlink
Adodc1.CommandType = adCmdUnknown
Adodc1.RecordSource = "select * from 图书借还表 "
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
End Sub
Private Sub Command4_Click()
Adodc1.CommandType = adCmdUnknown
Adodc1.RecordSource = "select * from 图书借还表 where 读者编号='" & Val(Text1) & "'"
Adodc1.Refresh
End Sub 展开
展开全部
你也没说是哪一句出问题
应该是下面这一句
Adodc1.RecordSource = "select * from 图书借还表 where 读者编号='" & Val(Text1) & "'"
Val(Text1) 是把Text1中的内容转化为数值,但是:读者编号='" & Val(Text1) & "'"这里却加了引号,
所以矛盾
如果 读者编号是数字,这句改为
Adodc1.RecordSource = "select * from 图书借还表 where 读者编号=" & Val(Text1)
如果 读者编号是字符串,这句改为
Adodc1.RecordSource = "select * from 图书借还表 where 读者编号=‘" & trim(Text1) & “’”
应该是下面这一句
Adodc1.RecordSource = "select * from 图书借还表 where 读者编号='" & Val(Text1) & "'"
Val(Text1) 是把Text1中的内容转化为数值,但是:读者编号='" & Val(Text1) & "'"这里却加了引号,
所以矛盾
如果 读者编号是数字,这句改为
Adodc1.RecordSource = "select * from 图书借还表 where 读者编号=" & Val(Text1)
如果 读者编号是字符串,这句改为
Adodc1.RecordSource = "select * from 图书借还表 where 读者编号=‘" & trim(Text1) & “’”
追问
我已经处理好了,谢谢
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询