System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi guys,
I'm getting error:-
System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near '='.
What could cause this ERRORR
My code below:-
Dim connString As String = "server=(local);database=Northwind;integrated
security=true;"
Dim objConnection As SqlConnection
objConnection = New SqlConnection(connString)
objConnection.Open()

Dim sSQL As String = "SELECT Sub_category_id,sub_category_text FROM
Sub_Category"

Dim objCommand As SqlCommand
objCommand = New SqlCommand(connString, objConnection)

Dim objDataReader As SqlDataReader
objDataReader =
objCommand.ExecuteReader(CommandBehavior.CloseConnection)

catlist.DataSource = objDataReader
catlist.DataBind()
 
Hi,

You need to remove the braces in the connection string for servername
server=(local) needs to be server=local.

Hope it helps.
 
Hi Ranganh and thanks for the email,
I don't think that is the error i tried inputting local but it says
SQL Server does
not exist and i have other aaplications connected to the DB with the same
connection String.

The Error is on line below :-
objDataReader = objCommand.ExecuteReader(CommandBehavior.CloseConnection)

Thats what the Error is saying!!
Any help any ideas!!
 
Does anyone have an idea what i'm doing WRONG!!


Patrick.O.Ige said:
Hi Ranganh and thanks for the email,
I don't think that is the error i tried inputting local but it says
SQL Server does
not exist and i have other aaplications connected to the DB with the same
connection String.

The Error is on line below :-
objDataReader = objCommand.ExecuteReader(CommandBehavior.CloseConnection)

Thats what the Error is saying!!
Any help any ideas!!
 
Back
Top