首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

vb中语法出错"标准表达式中数据类型不匹配"该怎么解决

2012-03-06 
vb中语法出错标准表达式中数据类型不匹配郁闷,搞了半天了,就是没找出问题来,这是我写的语句DimstuidadAs

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 是数字类型的 所以不用加单引号

热点排行