|
VB6 database query problems:
The code looks like this:
Where cbSearch is a drop-down list box, the connected database is the access2000 database
If txtSearch.Text = "" Then
MsgBox "Query criteria cannot be empty!", VbOKOnly + vbInformation, "Query"
Else
Adodc1.RecordSource = "select * from sales information table where"&Trim (cbSearch.Text)&"= '"&Trim (txtSearch.Text)&"'"
Adodc1.Refresh
If Adodc1.Recordset.EOF Then
MsgBox "No records found for this condition!", VbOKOnly + vbInformation, "Query"
End If
End If
The problem is, for example, when entering a condition in txtSearch, when the entered condition is different from the type in the database, vb pops up an error window: the data type in the standard expression does not match
For example Adodc1.RecordSource = "select * from sales information table where serial number = '"&Trim (txtSearch.Text)&"'"
This sequence number field is numeric in access, and a data type mismatch error in the standard expression will pop up
Because the&connector is used to connect the operands of two disks, whether it is a character or a numeric type, before the connection operation is performed.
'It is caused by the system first converting the operator number to a character type and then connecting. I do not want to change the database.
Seeking a solution. |
|