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 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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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";
|
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 & "'"
|
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()
|
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 ***
|
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.
| |
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.
|
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?
|
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
|
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.
|
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...
|
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,...
| |
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...
|
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,...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
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...
| |