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.SqlE xception: 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=ProN ET;uid=pro rpt;pwd=pr orpt"
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_MilesDCToPo ol_PostalC ode"
Dim myCommand As New SqlCommand(strAddSQL, cnConsOrders)
Dim parmSCACLinehaul As New SqlParameter("@strSCACLH", SqlDbType.Char, 4)
Dim parmPostalCode As New SqlParameter("@strPostalCo de", SqlDbType.VarChar, 9)
Dim parmMilesDCToPool As New SqlParameter("@strMilesDCT oPool", SqlDbType.Int)
parmSCACLinehaul.Value = drPool("SCACLinehaul")
parmPostalCode.Value = drPool("PostalCode")
parmMilesDCToPool.Value = drPool("MilesDCToPool")
myCommand.CommandType = CommandType.StoredProcedur e
myCommand.CommandText = strAddSQL
myCommand.Connection = cnConsOrders
myCommand.Parameters.Add(p armSCACLin ehaul)
myCommand.Parameters.Add(p armMilesDC ToPool)
myCommand.Parameters.Add(p armPostalC ode)
cnConsOrders.Open()
myCommand.ExecuteNonQuery( )
End Sub
Thanks for your help.
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.SqlE
Source Error:
Line 438: Dim objCommand As SqlCommand = New SqlCommand(strSQL, objConn)
Line 439: objConn.Open()
Line 440: Dim drPool As SqlDataReader = objCommand.ExecuteReader()
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=ProN
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_MilesDCToPo
Dim myCommand As New SqlCommand(strAddSQL, cnConsOrders)
Dim parmSCACLinehaul As New SqlParameter("@strSCACLH",
Dim parmPostalCode As New SqlParameter("@strPostalCo
Dim parmMilesDCToPool As New SqlParameter("@strMilesDCT
parmSCACLinehaul.Value = drPool("SCACLinehaul")
parmPostalCode.Value = drPool("PostalCode")
parmMilesDCToPool.Value = drPool("MilesDCToPool")
myCommand.CommandType = CommandType.StoredProcedur
myCommand.CommandText = strAddSQL
myCommand.Connection = cnConsOrders
myCommand.Parameters.Add(p
myCommand.Parameters.Add(p
myCommand.Parameters.Add(p
cnConsOrders.Open()
myCommand.ExecuteNonQuery(
End Sub
Thanks for your help.
You forgot the FROM clause in your SQL statement.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks hismightiness.
No problem... That happens way TOO often when we concatenate strings into SQL statements. It is easily overlooked. :)
ASKER
The stupid error message never tell you where and what the exact error is:(