Home > Software engineering >  Vb SQL query error
Vb SQL query error

Time:09-22

In vb for always prompt when the SQL query statement error, can you help me see this code where is there a problem?
 Dim strSQL As String 
Dim strCon (7) As String

Dim As Integer I


If Text1. Text & lt;> "" Then
If Check1. Value=https://bbs.csdn.net/topics/1 Then
StrCon (1)="cargo application. Application form, like '%" & amp; Text1. Text & amp; "% '
"The Else
StrCon (1)="cargo application. Application form number='" & amp; Text1. Text & amp; "'
"End the If
The Else
StrCon (1)=""
End the If


If Text2. Text & lt;> "" Then
If Check1. Value=https://bbs.csdn.net/topics/1 Then
StrCon (2)="application form for the goods. The awb like '%" & amp; Text2. Text & amp; "% '
"The Else
StrCon (2)="application form for the goods. The awb='" & amp; Text2. Text & amp; "'
"End the If

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


If Text3. Text & lt;> "" Then
If Check1. Value=https://bbs.csdn.net/topics/1 Then
StrCon (3)="customer information table. Address like '%" & amp; Text3. Text & amp; "% '
"The Else
StrCon (3)="customer information table. Address='" & amp; Text3. Text & amp; "'
"End the If

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

If Text4. Text & lt;> "" Then
If Check1. Value=https://bbs.csdn.net/topics/1 Then
StrCon (4)="application form for the goods. The recipient address like '%" & amp; Text4. Text & amp; "% '
"The Else
StrCon (4)="application form for the goods. The recipient address='" & amp; Text4. Text & amp; "'
"End the If
The Else
StrCon (4)=""
End the If

If Text5. Text & lt;> "" Then
If Check1. Value=https://bbs.csdn.net/topics/1 Then
StrCon (5)="customer information form. Customer name like '%" & amp; Text5. Text & amp; "% '
"The Else
StrCon (5)="customer information form. Customer name='" & amp; Text5. Text & amp; "'
"End the If
The Else
StrCon (5)=""
End the If
If Text6. Text & lt;> "" Then
If Check1. Value=https://bbs.csdn.net/topics/1 Then
StrCon (6)="application form for the goods. The recipient's name like '%" & amp; Text6. Text & amp; "% '
"The Else
StrCon (6)="application form for the goods. The recipient name='" & amp; Text6. Text & amp; "'
"End the If
The Else
StrCon (6)=""
End the If
If Combo2. Text="according to the requisition number query" Then
If Text7. Text & lt;> "" Then
StrCon (7)="cargo application. Application form number='" & amp; Text7. Text & amp; "'
"The Else
StrCon (7)=""
End the If
End the If

If Combo1. Text="query" according to the destination Then
If Text7. Text & lt;> "" Then
StrCon (7)="application form for the goods. The recipient address='" & amp; Text7. Text & amp; "'
"The Else
StrCon (7)=""
End the If
End the If

If Combo2. Text="according to the sender query" Then
If Text7. Text & lt;> "" Then
StrCon (7)="customer information form. Customer name='" & amp; Text7. Text & amp; "'
"The Else
StrCon (7)=""
End the If
End the If

If Combo2. Text="according to the recipient query" Then
If Text7. Text & lt;> "" Then
StrCon (7)="application form for the goods. The recipient name='" & amp; Text7. Text & amp; "'
"The Else
StrCon (7)=""
End the If
End the If

If Combo2. Text="condition according to express queries Then
If Text7. Text & lt;> "" Then
StrCon (7)="in transit tracking information table. Transportation status='" & amp; Text7. Text & amp; "'
"The Else
StrCon (7)=""
End the If
End the If


For I=1 To 7
If strCon (I) & lt;> "" Then
StrSQL=strSQL + "and" + strCon (I)
End the If
Next

StrSQL="select goods application. Application form, application form for the goods. The awb, the customer information table. Address," _
& "Application form for the goods. The recipient address, the customer information form. Customer name, application form for the goods. The recipient's name, in road tracking information table. Application form from goods transport state, in road tracking information table, the customer information table" _
& "Where goods application. Application form number=in road tracking information table. Application form and application form for the goods. The awb=in road tracking information table. The awb"


Adodc1. The ConnectionString="Provider=MSDASQL. 1; Persist Security Info=False; User ID=sa; Data Source=logistics management; Initial Catalog=W - L "
Adodc1. CursorLocation=adUseClient
Adodc1.Com mandType=adCmdText
Adodc1. RecordSource strSQL=
Adodc1. Refresh
The Set DataGrid1. The DataSource=Adodc1

CodePudding user response:

 Debug. Print strSQL 

And then post the statement SSMS performed in the query window, pointed out the mistake will naturally,
Through the manual to determine the fault location,

CodePudding user response:

Sql query sentence writing seems incorrect.

CodePudding user response:

SQL query language main structure is:
The Select query fields from the table name Where the query condition statement/sorting grouping statement or statements

CodePudding user response:

The SQL statement printed, copy and paste to the query analyzer manually run inside, if necessary can also step through, after again,

CodePudding user response:

Name in Chinese, and trying to delete some look on the SQL statement, estimation is your wrong tables and fields, such as a field doesn't exist in this table, you still go to. It

CodePudding user response:

Chinese may have half Angle brackets [], wrap,

CodePudding user response:

StrSQL="select goods application. Application form, application form for the goods. The awb, the customer information table. Address," _
& "Application form for the goods. The recipient address, the customer information form. Customer name, application form for the goods. The recipient's name, in road tracking information table. Application form from goods transport state, in road tracking information table, the customer information table" _
& "Where goods application. Application form number=in road tracking information table. Application form and application form for the goods. The awb=in road tracking information table. The awb and goods form. The customer ID=customer information table. The customer ID"

No customer information table associated conditions are given,

CodePudding user response:

Through learning, just have a project will involve the SQL database,
  • Related