Private Sub Command1_Click ()
'search administrator functions
If Text1. Text & lt;> 0 Then
Adodc1. Recordsourse="select * from administrator index table where the administrator username=Text1. Text"
The Else
Adodc1. RecordSource="select * from administrator index table where name=Text1. The Text"
End Sub
Adodc1 has been connected to the library management system, adodc1 recordsource is administrator index table
How to change the code can query the records and the records show that in the datagrid??????
CodePudding user response:
To tell the truth, you send this kind of unknown origin of the code, I don't like serious written learned programming, even as I change depend on spectrum under this lot ah:Option Explicit
The Public Function QuotedStr (ByVal sValue As String) As String
QuotedStr="'" & amp; The Replace (sValue, "'", "'") & amp; "'
"End the Function
Private Sub Command1_Click ()
'search administrator functions
If Len (Text1. Text) & lt;> 0 Then
Adodc1. Recordsourse="select * from administrator index table where the administrator user name=" & amp; QuotedStr (Text1. Text)
ElseIf Len (Text2. Text) & lt;> 0 Then
Adodc1. RecordSource="select * from administrator index table where name=" & amp; QuotedStr (Text2. Text)
End Sub
CodePudding user response:
Upstairs positive solution, this kind of problem as long as in the debug print your SQL statements to take a look at will know where is wrongCodePudding user response:
Adodc1. Recordsourse="select * from administrator index table where the administrator user name='" & amp; Text1. Text & amp;" '"