Home > Software engineering >  Ado controls of the vb how to use the SQL statement beginning with known string (the string into a p
Ado controls of the vb how to use the SQL statement beginning with known string (the string into a p

Time:10-04

A great god solution: how to use ado controls of the vb SQL statement beginning with known string (the string into a public variable) fields, and the datagrid control to display the ado data, to find the
SELECT *
The FROM StudentInfo
WHERE StudentClassID Like '% % str1 AND StudentDepart="str2";
This is my play, I do not know why did not achieve the

CodePudding user response:

SELECT *
The FROM StudentInfo
WHERE StudentClassID Like '% "& amp; Str1 & amp;" % 'AND StudentDepart=' "& amp; Str2 & amp;" '

CodePudding user response:

I changed in the ADODC attributes or no
SELECT *
The FROM StudentInfo
WHERE StudentClassID Like '% "& amp; Str1 + "& amp; 'AND StudentDepart=' "& amp; Str2 & amp;" ';

CodePudding user response:

Like '% "& amp; Str1 & amp;" % 'AND StudentDepart=' "& amp; Str2 & amp;" '

CodePudding user response:

SELECT *
The FROM StudentInfo
WHERE StudentClassID Like '% "& amp; Str1 & amp;" % 'AND StudentDepart=' "& amp; Str2 & amp;" '
Yes, this time or not, please do. Thank you for your help

CodePudding user response:

Entangled with this problem for a long time, want to cry, crazy!

CodePudding user response:

The statement did not say that have no eligible records

CodePudding user response:

Search field, or query record?

CodePudding user response:

Record

CodePudding user response:

SQL="select... The from... Where the field name like "& amp; "' beginning with known string" & amp; "% '"

CodePudding user response:

Vc access ado where variable string

CodePudding user response:

Vc access ado where variable string

CodePudding user response:

Now that use the variable, will not be able to assign attributes, when the design need to assignment in your code,
 Private Sub Command1_Click () 
Str1=...
Str2=...
Adodc1. RecordSource="SELECT *" & amp; _
"FROM StudentInfo" & amp; _
"WHERE StudentClassID Like '%" & amp; Str1 & amp; "% '" & amp; _
"AND StudentDepart='" & amp; Str2 & amp; "'
"Adodc1. Refresh
End Sub

CodePudding user response:

Now that use the variable, will not be able to assign attributes, when the design need to assignment in your code,
 Private Sub Command1_Click () 
Str1=...
Str2=...
Adodc1. RecordSource="SELECT *" & amp; _
"FROM StudentInfo" & amp; _
"WHERE StudentClassID Like '%" & amp; Str1 & amp; "% '" & amp; _
"AND StudentDepart='" & amp; Str2 & amp; "'
"Adodc1. Refresh
End Sub
  • Related