问题标题:
dimstrsqlasstringIfText1.Text""ThenAdodc1.Recordset.CloseIfVal(Text1.Text)0Thenstrsql="select*fromnamewherename="&Trim(Text1.Text)'Trim去掉前后空格Elsestrsql="select*fromnamewherename='"&Trim(Text1.Text)&"'"EndIfA
更新时间:2024-04-28 04:23:28
问题描述:

dimstrsqlasstring

IfText1.Text""Then

Adodc1.Recordset.Close

IfVal(Text1.Text)0Then

strsql="select*fromnamewherename="&Trim(Text1.Text)'Trim去掉前后空格

Else

strsql="select*fromnamewherename='"&Trim(Text1.Text)&"'"

EndIf

Adodc1.CommandType=adCmdText

Adodc1.Recordset.Openstrsql

SetDataGrid1.DataSource=Adodc1

Else

SetDataGrid1.DataSource=Nothing

EndIf

以上查找字母或中文都不会报错,但查找的为数字就会报错”标准表达式中数据类型不匹配“

江世英回答:
  strsql="select*fromnamewherename="&Trim(Text1.Text)'Trim去掉前后空格你这个name在数据库中是字符串的所有必须加上单引号.
其它推荐
热门其它推荐
首页
栏目
栏目
栏目
栏目