473,803 Members | 3,159 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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.Sql Client.SqlComma nd.ExecuteReade r(CommandBehavi or
cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
System.Data.Sql Client.SqlComma nd.ExecuteReade r()
Labor.Labor.Pag e_Load(Object sender, EventArgs e) in
c:\inetpub\wwwr oot\labor\labor .aspx.cs:72
System.Web.UI.C ontrol.OnLoad(E ventArgs e)
System.Web.UI.C ontrol.LoadRecu rsive()
System.Web.UI.P age.ProcessRequ estMain()
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.Sql Client.SqlDataR eader reader = sqlCmd.ExecuteR eader();
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
Nov 16 '05 #1
1 3426
You spelled 'SELECT' as 'SELCT'.

"bdastani" <bd******@gmail .com> wrote in message
news:69******** *************** ***@posting.goo gle.com...
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.Sql Client.SqlComma nd.ExecuteReade r(CommandBehavi or
cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
System.Data.Sql Client.SqlComma nd.ExecuteReade r()
Labor.Labor.Pag e_Load(Object sender, EventArgs e) in
c:\inetpub\wwwr oot\labor\labor .aspx.cs:72
System.Web.UI.C ontrol.OnLoad(E ventArgs e)
System.Web.UI.C ontrol.LoadRecu rsive()
System.Web.UI.P age.ProcessRequ estMain()
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.Sql Client.SqlDataR eader reader = sqlCmd.ExecuteR eader();
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

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4368
by: Roger R. Smith | last post by:
I see this error in my ASP .NET code: I am trying to execute the following: private const string SQL_SELECT_USER = "SELECT User.Email, User.FirstName, User.LastName, User.Status, User.Phone, User.Privs FROM User INNER JOIN Login ON User.UserId = Login.UserId WHERE Login.UserId = @UserId AND Login.Password = @Password";
2
1955
by: Patrick.O.Ige | last post by:
Can anybody body tell me what my error is here its saying :- System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'WHERE'. SQLString = "UPDATE treetable SET " & _ "ParentID = '" & ParentID & "', " & _ "FileCategory = '" & Replace(FileCategory, "'", "''") & "', " & _ "NavigateUrl = '" & Replace(NavigateUrl, "'", "''") & "', " & _ "Target = '" & Target & "', " & _ "WHERE FileCategoryID ='" & FileCategoryID & "'"
3
6057
by: Patrick.O.Ige | last post by:
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()
4
2343
by: Patrick Olurotimi Ige | last post by:
why is this giving me error System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near '='.?? my code is in c# strSql = "Update addmessage Set message = '"+null+"' Where ID=" +ID; strSql = "Update addmessage Set message = '"+message+"' Where ID=" +ID; *** Sent via Developersdex http://www.developersdex.com ***
1
11255
by: Sandesh | last post by:
Hello All, Me saying " has any body come across such error would be underestimating". Well I am getting a very peculiar and unique error "Line 1: Incorrect syntax near 'Actions'." Explaining you the scene is the following Stored Proc.
6
2990
by: martin1 | last post by:
I just use DataSet to bind DataSetGrid and display from SQL DB. when starting run in Visual Studio 2005, get "Line 1: Incorrect syntax near '1'" error message from below fill line, objDataAdapter.Fill(objDataSet, "mindata") any help is greatly appriciated.
1
3634
by: harleedavidson | last post by:
Using SqlBulkCopy.WriteToServer to upload a datatable and getting: System.Data.SqlClient.SqlException Line 1: Incorrect syntax near 'COLLATE'. Database Server is SQL2000, database in in 6.5 compatibility mode. No error when targeting SQL2000 database in 8.0 compatibility mode. Is this specific to 6.5 and is there a workaround?
1
2356
by: iporter | last post by:
In the following code, the two Response.Write statements output exactly the same - I can copy and paste both into Query Analyzer, and run them fine. However, if I comment out line 3, the assignment of "SELECT T..." to the variable query, the last line produces the error: Line 1: Incorrect syntax near '<'. Many thanks in advance for any explanation - the problem is tearing my hair out!! Iain
1
31207
by: Ruth413 | last post by:
Hello - I am getting the these errors in my sql 2005 generated script. I am stuck with first error. Please help.... Msg 102, Level 15, State 1, Line 3 Incorrect syntax near '('. Msg 319, Level 15, State 1, Line 11 Incorrect syntax near the keyword 'with'. If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon.
0
9700
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9564
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10546
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10292
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7603
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5498
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5627
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4275
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2970
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.