我收到错误,说我的语法不正确,但对我来说一切都很好。
在使用datareader的行上,它表示“And”一词的语法不正确。
我尝试过多次修改,试着让它无效。有什么帮助吗?
SQL: -
Dim sqlline1 As String = String.Format("Select count(debtor_id) As
numbernew, sum(debtor_original_debt) As valuenew, SUM(debtor_balance)
From debtors Where debtor_cohort_id Like {0} + {2} And (debtor_client_id >=
{0} And debtor_client_id <= {1})", clientid_start, clientid_end, Cohort4)
将错误发挥到: -
Public Function populatestringwithsql(command As String) As String
Dim conn As String = "a server connection"
Dim i = 1
Dim fields(15) As String
Dim numberoffields As Integer
Using connObj As New SqlClient.SqlConnection(conn)
Using cmdObj As New SqlClient.SqlCommand(command, connObj)
connObj.Open()
Dim readobj As SqlClient.SqlDataReader = cmdObj.ExecuteReader()
Dim schematable As DataTable = readobj.GetSchemaTable()
readobj.Close()
For Each dr As DataRow In schematable.Rows
numberoffields = schematable.Columns.Count
For Each dc As DataColumn In schematable.Columns
fields(i) = dc.ColumnName
i += 1
Next
Next
Using readerObj As SqlDataReader = cmdObj.ExecuteReader
'This will loop through all returned records
While readerObj.Read
If fields(1) <> "" Then
fields(1) = readerObj(fields(1)).ToString
End If
If fields(2) <> "" Then
fields(2) = readerObj(fields(2)).ToString
End If
If fields(3) <> "" Then
fields(3) = readerObj(fields(3)).ToString
End If
If fields(4) <> "" Then
fields(4) = readerObj(fields(4)).ToString
End If
If fields(5) <> "" Then
fields(5) = readerObj(fields(5)).ToString
End If
If fields(6) <> "" Then
fields(6) = readerObj(fields(6)).ToString
End If
If fields(7) <> "" Then
fields(7) = readerObj(fields(7)).ToString
End If
If fields(8) <> "" Then
fields(8) = readerObj(fields(8)).ToString
End If
If fields(9) <> "" Then
fields(9) = readerObj(fields(9)).ToString
End If
If fields(10) <> "" Then
fields(10) = readerObj(fields(10)).ToString
End If
If fields(11) <> "" Then
fields(11) = readerObj(fields(11)).ToString
End If
If fields(12) <> "" Then
fields(12) = readerObj(fields(12)).ToString
End If
If fields(13) <> "" Then
fields(13) = readerObj(fields(13)).ToString
End If
If fields(14) <> "" Then
fields(14) = readerObj(fields(14)).ToString
End If
If fields(15) <> "" Then
fields(15) = readerObj(fields(15)).ToString
End If
End While
End Using
connObj.Close()
End Using
End Using
Dim stringend As Text.StringBuilder
For Each field In fields
stringend.Append(field)
Next
Return stringend.ToString
End Function
我已尝试过所有调试途径而且没有运气。
答案 0 :(得分:1)
查看var config = {
fieldsets : [
{
title : 'Quote Essentials',
description : 'Some',
fields : [
{
label : 'What type of project is this for?',
required : true,
class : '',
type : 'input',
inputType : 'text',
hint : 'For example: company uniforms, clothing line, school events, etc.',
id : ''
},
{
label : 'How many total items do you need?',
required : true,
class : '',
type : 'input',
inputType : 'text',
hint : 'Please note: the minimum order size is 24 pieces.',
id : ''
},
...
,您似乎正在尝试连接Where debtor_cohort_id Like {0} + {2} And ...
和client_id
。除非client_id或cohort4包含通配符,否则使用=而不是LIKE。
您可能需要围绕比较cohort4
最简单的方法是打印你的sqlline1变量,以准确显示它的错误。