还是不明白哪里出错了,可以帮我看看吗?Private Sub Command1_Click()Dim strsql As StringIf Text1.Text "" ThenAdodc1.Recordset.CloseIf Val(Text1.Text) > 0 Thenstrsql = "select * from name where name='" & Trim(Text1.Text) & "'"End IfAdodc1

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/11 04:19:52
还是不明白哪里出错了,可以帮我看看吗?Private Sub Command1_Click()Dim strsql As StringIf Text1.Text 0 Thenstrsql = "select * from name where name='" & Trim(Text1.Text) & "'"End IfAdodc1" />

还是不明白哪里出错了,可以帮我看看吗?Private Sub Command1_Click()Dim strsql As StringIf Text1.Text "" ThenAdodc1.Recordset.CloseIf Val(Text1.Text) > 0 Thenstrsql = "select * from name where name='" & Trim(Text1.Text) & "'"End IfAdodc1
还是不明白哪里出错了,可以帮我看看吗?
Private Sub Command1_Click()
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) & "'"
End If
Adodc1.CommandType = adCmdText
Adodc1.Recordset.Open strsql
Set DataGrid1.DataSource = Adodc1
Else
Set DataGrid1.DataSource = Nothing
End If
End Sub
我在text1裏输入的数字可以收索并显示出来,但输入的是文字就报错
说这句有问题Adodc1.Recordset.Open strsql
我想实现无论输入什麼都可以收索并显示出来,十分感激

还是不明白哪里出错了,可以帮我看看吗?Private Sub Command1_Click()Dim strsql As StringIf Text1.Text "" ThenAdodc1.Recordset.CloseIf Val(Text1.Text) > 0 Thenstrsql = "select * from name where name='" & Trim(Text1.Text) & "'"End IfAdodc1
Private Sub Command1_Click()
Dim strsql As String
If Text1.Text "" Then
Adodc1.Recordset.Close
strsql = "select * from name where name='" & Trim(Text1.Text) & "'"
Adodc1.CommandType = adCmdText
Adodc1.Recordset.Open strsql
Set DataGrid1.DataSource = Adodc1
Else
Set DataGrid1.DataSource = Nothing
End If
End Sub
把内层的If Then去掉.
你要的条件是Name,看来是一个文本,那么你判断数字( If Val(Text1.Text) > 0)做什么用?