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

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()
 
G

Guest

Hi,

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

Hope it helps.
 
G

Guest

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!!
 
P

Patrick.O.Ige

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!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top