Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 275
  • Last Modified:

Line 1: Incorrect syntax near '='.

I think it's something easy to detect but I can't find what's wrong:( Run into this error:

Line 1: Incorrect syntax near '='.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near '='.

Source Error:

Line 438:        Dim objCommand As SqlCommand = New SqlCommand(strSQL, objConn)
Line 439:        objConn.Open()
Line 440:        Dim drPool As SqlDataReader = objCommand.ExecuteReader()     <---IN RED
Line 441:
Line 442:


The function that I was trying to call:

Sub Get_Pro1(ByVal OriginLocation As String)
        Dim strConn1 As String = "Server=RFD1;database=ProNET;uid=prorpt;pwd=prorpt"
        Dim objConn As SqlConnection = New SqlConnection(strConn1)
        Dim strSQL As String = "Select SCACLinehaul, MilesDCToPool, PostalCode from vw_Pool_Locations" _
                                           & "Where SailingDC = OriginLocation"

        Dim objCommand As SqlCommand = New SqlCommand(strSQL, objConn)
        objConn.Open()
        Dim drPool As SqlDataReader = objCommand.ExecuteReader()


        Dim strAddSQL As String = "web_AddSCACLH_MilesDCToPool_PostalCode"
        Dim myCommand As New SqlCommand(strAddSQL, cnConsOrders)

        Dim parmSCACLinehaul As New SqlParameter("@strSCACLH", SqlDbType.Char, 4)
        Dim parmPostalCode As New SqlParameter("@strPostalCode", SqlDbType.VarChar, 9)
        Dim parmMilesDCToPool As New SqlParameter("@strMilesDCToPool", SqlDbType.Int)

        parmSCACLinehaul.Value = drPool("SCACLinehaul")
        parmPostalCode.Value = drPool("PostalCode")
        parmMilesDCToPool.Value = drPool("MilesDCToPool")

        myCommand.CommandType = CommandType.StoredProcedure
        myCommand.CommandText = strAddSQL
        myCommand.Connection = cnConsOrders
        myCommand.Parameters.Add(parmSCACLinehaul)
        myCommand.Parameters.Add(parmMilesDCToPool)
        myCommand.Parameters.Add(parmPostalCode)

        cnConsOrders.Open()
        myCommand.ExecuteNonQuery()

    End Sub

Thanks for your help.
0
john0879
Asked:
john0879
  • 3
  • 2
1 Solution
 
hismightinessCommented:
You forgot the FROM clause in your SQL statement.
0
 
hismightinessCommented:
Nevermind, I mean this:

        Dim strSQL As String = "Select SCACLinehaul, MilesDCToPool, PostalCode from vw_Pool_Locations " & _
                                           "Where SailingDC = OriginLocation"

A space after "vw_Pool_Locations" and "WHERE".
0
 
john0879Author Commented:
Thanks hismightiness.
0
 
hismightinessCommented:
No problem...  That happens way TOO often when we concatenate strings into SQL statements.  It is easily overlooked.  :)
0
 
john0879Author Commented:
The stupid error message never tell you where and what the exact error is:(
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now