[SqlException: Line 1: Incorrect syntax near '*'.]

B

bdastani

I am trying to initialize a dataReader in C#, but I keep on gettin an
exception error stating the following:

[SqlException: Line 1: Incorrect syntax near '*'.]
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
System.Data.SqlClient.SqlCommand.ExecuteReader()
Labor.Labor.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\labor\labor.aspx.cs:72
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()


My code is the following:

// SQL Connection
sqlConnect = new SqlConnection("Data Source=" + server +";Initial
Catalog=" + database +";User ID=" + uid +";Password=" + password);

sqlConnect.Open();

sql="";
sql="SELCT * FROM tOrder";
SqlCommand sqlCmd = new SqlCommand( sql,sqlConnect);

System.Data.SqlClient.SqlDataReader reader = sqlCmd.ExecuteReader();


I checked the connection state and it is equal to "Open" so apparenlty
the connection to the DB was made. But I can not create a reader to
read the table.

Please help.

Thank you,
Behzad
 

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

Top