Program content is as follows:
Private Sub Command1_Click ()
Dim strSql As String
If Text1. Text & lt;> "" Then
Adodc1. You. Close
If Val (Text1. Text) & gt; 0 Then
StrSql="select * from table1 where num=" & amp; Trim (Text1. Text)
The Else
StrSql="select * from table1 where name='" & amp; Trim (Text1. Text) & amp; "'
"End the If
Adodc1.Com mandType=adCmdText
Adodc1. You. Open strSql
The Set DataGrid1. The DataSource=Adodc1
The Else
The Set DataGrid1. The DataSource=Nothing
End the If
End Sub
Where is the problem? Why shows the blank in the search after the plugin
CodePudding user response:
This is a PE teacher to teach programming?Don't direct operation Adodc1. You, can affect the function of normal!!!!!!
CodePudding user response:
No qualified recordCodePudding user response:
Please give Adodc1 ConnectionString assignment string concatenation, and use the following code style:Private Sub Command1_Click ()
Dim STRSQL As String
Adodc1. The ConnectionString="Provider=Microsoft. Jet. The OLEDB. 4.0; Data Source=D: \ \ Program Files \ Microsoft Visual Studio \ vb98 \ nwind MDB. Persist Security Info=False "
If Text1. Text & lt;> "" Then
If Val (Text1. Text) & gt; 0 Then
STRSQL="select * from Customers where the Customer ID=" & amp; Trim (Text1. Text)
The Else
STRSQL="select * from Customers where CustomerID='" & amp; Trim (Text1. Text) & amp; "'
"End the If
Adodc1. RecordSource STRSQL=
Adodc1. Refresh
The Set DataGrid1. The DataSource=Adodc1
The Else
The Set DataGrid1. The DataSource=Nothing
End the If
End Sub
Amend the code to your database name, path and name of the table,
CodePudding user response:
Another fun, like statements in the ide and compiled implementation effect is not consistent,