读书人

vb中语法出错quot;标准表达式中数据类型不

发布时间: 2012-03-06 20:47:55 作者: rapoo

vb中语法出错"标准表达式中数据类型不匹配"
郁闷,搞了半天了,就是没找出问题来,
这是我写的语句
Dim stuidad As Date
Dim SEX As Double
SEX = Val(Text1(0).Text)
stuidad = Text2.Text
Set stucon = New ADODB.Connection
Set stucom = New ADODB.Command
stucon.Open "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=E:\vb\tuimag1.mdb "
stucom.ActiveConnection = stucon
stucom.CommandType = adCmdText
stucom.CommandText = "update stuinfo set stubirthdate= ' " & stuidad & " ' where stuid= ' " & SEX & " ' "
stucom.Execute

执行的时候就提示范区'"标准表达式中数据类型不匹配 "
我的stubirthdate为日期型字段!不知为何直接对日期进行修改可以,但是把他作为条件就会出错这个错误提示,还有一个STUID字段为DOUBLE的类型的,把他作为条件也不行!!文本类型的都可以做为条件,不知何故,请高人明示!!!!

[解决办法]

stucom.CommandText = "update stuinfo set stubirthdate= ' " & stuidad & " ' where stuid= ' " & SEX & " ' "
改成:
stucom.CommandText = "update stuinfo set stubirthdate= ' " & stuidad & " ' where stuid= " & SEX

因为 stuid 是数字类型的 所以不用加单引号

读书人网 >VB

热点推荐