Home > Software engineering >  Why vb, in result that input fuzzy query after 90, 90% is always a string has not closed before guid
Why vb, in result that input fuzzy query after 90, 90% is always a string has not closed before guid

Time:09-18

If txtGrade. Text & lt;> "" Then
If chkMoHu. Value=https://bbs.csdn.net/topics/1 Then
StrCon (5)="SC. Grade like '" & amp; TxtGrade. Text & amp; "%", "
The Else
StrCon (5)="SC. Grade='" & amp; TxtGrade. Text & amp; "'
"End the If

The Else
StrCon (5)=""
End the If


StrSQL="select SC. Sno, Student, Sname, SC. Cno," _
& "Course. Cname, SC. Grade the from SC, Student, Course" _
& "Where SC. Sno=Student. Sno and SC. Cno=Course. Cno"
For I=1 To 5
If strCon (I) & lt;> "" Then
StrSQL=strSQL + "and" + strCon (I)
End the If
Next


Adodc1. The ConnectionString="Provider=MSDASQL. 1; Persist Security Info=False; User ID=sa; Data Source=ST; Initial Catalog=S - T "
Adodc1. CursorLocation=adUseClient
Adodc1.Com mandType=adCmdText
Adodc1. RecordSource strSQL=
[b] Adodc1. Refresh
After debugging display error in adodc1. Refresh the, can you help me take a look at where is there a problem? thank you

CodePudding user response:

% less behind a single quotation marks in English,

CodePudding user response:

This problem, the first thing you want to analyze the "SQL statement" string is legal,

It prompts "runtime error", you point the "debug" button,
Then, the interrupt IDE, suspended in the cause of abnormal statement execution,
You press the keyboard "Ctrl + G" immediately open the window, type the following command and press the enter key:
? StrSQL
It will take you "compose the SQL statements" content displayed,
Yourself and see what's the problem with this query, maybe you know is what reason, how to correct code.

CodePudding user response:

StrCon (5)="SC. Grade like '" & amp; TxtGrade. Text & amp; "%" to "SC. Grade like '%" & amp; TxtGrade. Text & amp; "% '"

CodePudding user response:

All commented On the Error Resume Next statement, in VB6 IDE,
The error and then click the debugging, the cursor will stop error in the statement,
Or
In doubt may have a logical error statements in advance to set breakpoints, run through the breakpoint interrupt,

At this point can be used in the immediate window
? The variable name
Or
? The function name () function parameter
Or
Process (parameters)
Auxiliary debugging,

CodePudding user response:

Pay attention to the results of field data is digital or character field, both the SQL query sentence writing, character field fuzzy queries are available, and can only use numerical fields & gt;=, & lt;=to distinguish,

CodePudding user response:

StrCon (5)="SC. Grade like '" & amp; TxtGrade. Text & amp; "% '"
  • Related