首页 > 中学考试杂题 > 题目详情
dim strsql as stringIf Text1.Text "" ThenAdodc1.Recordset.Cl
题目内容:
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 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
以上查找字母或中文都不会报错,但查找的为数字就会报错”标准表达式中数据类型不匹配“
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
以上查找字母或中文都不会报错,但查找的为数字就会报错”标准表达式中数据类型不匹配“
本题链接: