Wednesday, March 7, 2012

error-Line 1: Incorrect syntax near =

hi,

i got this error when i run app.

-----
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 40: Dim adpt As New SqlDataAdapter("SELECT * FROM SMS_student_class_master WHERE" & _
Line 41: "stud_id=" & sid, con)
Line 42: adpt.Fill(ds, "SMS_student_class_master")
Line 43: txt.Text = ds.Tables.Item("roll_no").ToString
Line 44: con.Close()

Source File: c:\inetpub\wwwroot\aspnet\sms\assignment_d.aspx.vb Line: 42
---

what should i do?
anyone have any idea?
plz give solution.
it's urgent.

thanks in advanceThis error indicates that there is an error in your sql statement. It looks like you do not have a space after your WHERE keyword.

hope this does the trick,
sivilian|||I think you have forgotten to put a space after WHERE and before stud_id

According to your string that you have formatted in Line 40 and 41, the sql string that will comes up will be like so

SELECT * FROM SMS_student_class_master WHEREstud_id=123

You should have put the string like below:

Dim adpt As New SqlDataAdapter("SELECT * FROM SMS_student_class_master WHERE " & _
"stud_id=" & sid, con)

No comments:

Post a Comment