Reputation: 13
I have this problem when I'm trying to fill my datagridview. I defined a connection to SQL Server, opened it and defined a SqlCommand
and a reader.
The problem is when I'm trying to execute the reader with the code below it gives me the error
Syntax error near "="
on the line that I try to execute the reader.
Dim sqlCommand1 As New SqlCommand("SELECT conItemName, conItemNumber, conClassName " & _
"FROM Constant" & _
"WHERE (Constant.conClassName = 'BoreholeType')", SesConn)
Dim tReader1 As SqlDataReader = sqlCommand1.ExecuteReader
Upvotes: 0
Views: 379
Reputation: 432311
"FROM Constant" & _
should be
"FROM Constant " & _
Otherwise, you have this missing space that causes the syntax error
... FROM ConstantWHERE (Constant.conClassName = 'BoreholeType')
Upvotes: 3