Home > Software engineering >  Vb how to quickly retrieve?
Vb how to quickly retrieve?

Time:09-25


The query interface is the teaching material, I'm using the adodc database connection, and then I want to achieve quick query, i.e., first select a query, the query keyword again according to the front of the method input (such as query methods for teaching material name, enter keywords for the teaching material), finally through the query in the query results will be displayed,

CodePudding user response:

Adodc1. RecordSource="Select * from table name where" & amp; Combo1. Text & amp; "Like '%" & amp; Text1. Text & amp; "% '"

CodePudding user response:

Not a word can solve this problem, because, after you click Combo1, is actually a query query conditions of the field, but a data table data type of each field is different, so the query way also is different, need according to the data type of the field set different query methods, character data, for example, you can use Leke keywords, but digital type of data, date type data will not be able to use the key word, such as today is a little thing, can't give you an example, in the evening to do one for you,

CodePudding user response:

I'm sorry! Just got the wrong number, and the Like into Leke.

CodePudding user response:

refer to the second floor u013249970 response:
is not a word can solve this problem, because, after you click Combo1, is actually a query query conditions of the field, but a data table data type of each field is different, so the query the way also is different, need according to the data type of the field set different query methods, character data, for example, you can use Leke keywords, but digital type of data, date type data will not be able to use the key word, such as today is a little thing, can't give you an example, in the evening to do one for you,

Their reading did out yesterday, thanks a lot

CodePudding user response:

refer to the second floor u013249970 response:
is not a word can solve this problem, because, after you click Combo1, is actually a query query conditions of the field, but a data table data type of each field is different, so the query the way also is different, need according to the data type of the field set different query methods, character data, for example, you can use Leke keywords, but digital type of data, date type data will not be able to use the key word, such as today is a little thing, can't give you an example, in the evening to do one for you,

But not out, keyword is input, can only lose of higher mathematics, not lose high number lookup

CodePudding user response:

reference 5 floor Outdoorsy reply:
but not out, keyword is input, can only lose of higher mathematics, not the lost high number lookup

If your query is a character data type, you can use the key words Like, give you an example:
 strSQL="select * from data table name where" & amp; Combo1. Text & amp; "Like '%" & amp; Text1. Text & amp; "% '" 

Like '% "& amp; Text1. Text & amp; "% is fuzzy query, such as your query is" higher mathematics ", as long as you input "high" or "like" or "number" or "learning" in any one word, can query,

CodePudding user response:

If you do not yet understand, your code is coming, I can give you see,

CodePudding user response:

The
reference 7 floor u013249970 response:
if you do not yet understand, your code is coming, I can give you see,

 Private Sub Command1_Click () 
If Combo1. Text="teaching material of" Then
Adodc2. RecordSource="select * from teaching material information where material name like '%" & amp; Text1. Text & amp; "% '
"Adodc2. Refresh
DataGrid1. Refresh
The Set DataGrid1. The DataSource=Adodc2
DataGrid1. Visible=True
If Adodc2. You. RecordCount & gt; 0 Then
The Else
MsgBox "input error, please input again!!!!!! "
End the If

The Else: Combo1. Text="press"
Adodc2. RecordSource="select * from teaching material information where press like '%" & amp; Text1. Text & amp; "% '
"Adodc2. Refresh
DataGrid1. Refresh
The Set DataGrid1. The DataSource=Adodc2
DataGrid1. Visible=True
If Adodc2. You. RecordCount & gt; 0 Then
The Else
MsgBox "input error, please input again!!!!!! "
End the If
End the If

End Sub


Now the problem is that I enter higher Numbers or higher can look up to the higher mathematics, but the input high number can't query, in didn't solve

CodePudding user response:

refer to the eighth floor Outdoorsy response:
Quote: refer to 7th floor u013249970 response:

If you do not yet understand, your code is coming, I can give you see,

Private Sub Command1_Click ()
If Combo1. Text="teaching material of" Then
Adodc2. RecordSource="select * from teaching material information where material name like '%" & amp; Text1. Text & amp; "% '
"Adodc2. Refresh
DataGrid1. Refresh
The Set DataGrid1. The DataSource=Adodc2
DataGrid1. Visible=True
If Adodc2. You. RecordCount & gt; 0 Then
The Else
MsgBox "input error, please input again!!!!!! "
End the If

The Else: Combo1. Text="press"
Adodc2. RecordSource="select * from teaching material information where press like '%" & amp; Text1. Text & amp; "% '
"Adodc2. Refresh
DataGrid1. Refresh
The Set DataGrid1. The DataSource=Adodc2
DataGrid1. Visible=True
If Adodc2. You. RecordCount & gt; 0 Then
The Else
MsgBox "input error, please input again!!!!!! "
End the If
End the If

End Sub

Now the problem is that I enter higher Numbers or higher can look up to the higher mathematics, but can't query input high number, do not know in not solve

Does it have to be like this:
 Dim strWhere As String 
Dim As Integer I

For I=1 To Len (Text1)
StrWhere=strWhere & amp; "The press like '%" & amp; Mid (Text1, I, 1) & amp; "% '
"If I & lt; Len (Text1) Then strWhere=strWhere & amp; "AND"
Next I
Adodc2. RecordSource="where the select * from teaching material information & amp; StrWhere

For example, input "higher education" was
 
Adodc2. RecordSource="select * from textbook information where press like 'high % %' AND press like '% teach %'"
can query to the higher education press,

CodePudding user response:

references 9 f of123 response:
Quote: refer to the eighth floor Outdoorsy response:

Quote: refer to 7th floor u013249970 response:

If you do not yet understand, your code is coming, I can give you see,

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related