Connecting Tech Pros Worldwide Forums | Help | Site Map

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

bdastani
Guest
 
Posts: n/a
#1: Nov 16 '05
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(Com mandBehavior
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

Marina
Guest
 
Posts: n/a
#2: Nov 16 '05

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


You spelled 'SELECT' as 'SELCT'.

"bdastani" <bdastani@gmail.com> wrote in message
news:6986f5cd.0410200757.7aea6a75@posting.google.c om...[color=blue]
> 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(Com mandBehavior
> 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[/color]


Closed Thread