dim strsql as stringIf Text1.Text "" ThenAdodc1.Recordset.CloseIf Val(Text1.Text) 0 Thenstrsql = "select * from name where name=" & Trim(Text1.Text) 'Trim去掉前后空格Elsestrsql = "select * from name where name='" & Trim(Text1.Text) & "'"End IfA

来源:学生作业帮助网 编辑:作业帮 时间:2024/09/09 00:26:38
dim strsql as stringIf Text1.Text
xJ@_eªHj -cgj D]KM5Uzjxn.23mL•p7s?0L0ucN2;1hxbI CC$:4G$@tZz?}`Г2g M*EXH"yz@LO_j4g&۹EQ@?|= pQİ0}x#ކafo=>oQeYT`lIC.^!C&4 FDSS0ijjJԝ7qL%钸VN$֦{ع{r;6l{8k]]h;UrxNbdڥvI[ PuW#'.l>vVtAjaDqM(s&IἛ4nZWgعwcV,)H~ Γzl=BD%rzL

dim strsql as stringIf Text1.Text "" ThenAdodc1.Recordset.CloseIf Val(Text1.Text) 0 Thenstrsql = "select * from name where name=" & Trim(Text1.Text) 'Trim去掉前后空格Elsestrsql = "select * from name where name='" & Trim(Text1.Text) & "'"End IfA
dim strsql as string
If Text1.Text "" Then
Adodc1.Recordset.Close
If Val(Text1.Text) 0 Then
strsql = "select * from name where name=" & Trim(Text1.Text) 'Trim去掉前后空格
Else
strsql = "select * from name where name='" & Trim(Text1.Text) & "'"
End If
Adodc1.CommandType = adCmdText
Adodc1.Recordset.Open strsql
Set DataGrid1.DataSource = Adodc1
Else
Set DataGrid1.DataSource = Nothing
End If
以上查找字母或中文都不会报错,但查找的为数字就会报错”标准表达式中数据类型不匹配“

dim strsql as stringIf Text1.Text "" ThenAdodc1.Recordset.CloseIf Val(Text1.Text) 0 Thenstrsql = "select * from name where name=" & Trim(Text1.Text) 'Trim去掉前后空格Elsestrsql = "select * from name where name='" & Trim(Text1.Text) & "'"End IfA
strsql = "select * from name where name=" & Trim(Text1.Text) 'Trim去掉前后空格你这个name在数据库中是字符串的所有必须加上单引号.