Link to home
Start Free TrialLog in
Avatar of john0879
john0879

asked on

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.
Avatar of hismightiness
hismightiness

You forgot the FROM clause in your SQL statement.
ASKER CERTIFIED SOLUTION
Avatar of hismightiness
hismightiness

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of john0879

ASKER

Thanks hismightiness.
No problem...  That happens way TOO often when we concatenate strings into SQL statements.  It is easily overlooked.  :)
The stupid error message never tell you where and what the exact error is:(