 |
| ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

March 21st, 2008, 11:15 AM
|
|
Authorized User
|
|
Join Date: Mar 2008
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Right the first thing that popped up after I had removed the try catch blocks was this error:
"SqlException was unhandled by user code: Incorrect syntax near the keyword 'Order'."
Which the exception detail as follows:
System.Data.SqlClient.SqlException was unhandled by user code
Message="Incorrect syntax near the keyword 'Order'."
Source=".Net SqlClient Data Provider"
ErrorCode=-2146232060
Class=15
LineNumber=1
Number=156
Procedure=""
Server="YOUR-1CA50768BA\\SQLEXPRESS"
State=1
StackTrace:
at System.Data.SqlClient.SqlConnection.OnError(SqlExc eption exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlDataReader.ConsumeMetaDat a()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteRead er(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderT ds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader( CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.RunExecuteReader( CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(Com mandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader()
at ASP.administration_orderallocation_aspx.ViewDestin ationBtn_Click(Object sender, EventArgs e) in c:\System\Administration\OrderAllocation.aspx:line 33
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEven t(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
|
|

March 21st, 2008, 11:20 AM
|
|
Authorized User
|
|
Join Date: Mar 2008
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Ah! Brilliant even more details. This time from a yellow screen of death!
Server Error in '/System' Application.
--------------------------------------------------------------------------------
Incorrect syntax near the keyword 'Order'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'Order'.
Source Error:
Line 31:
Line 32: conn.Open();
Line 33: reader = comm.ExecuteReader();
Line 34: if (reader.Read())
Line 35: {
Source File: c:\System\Administration\OrderAllocation.aspx Line: 33
Stack Trace:
[SqlException (0x80131904): Incorrect syntax near the keyword 'Order'.]
System.Data.SqlClient.SqlConnection.OnError(SqlExc eption exception, Boolean breakConnection) +98
System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException exception, Boolean breakConnection) +82
System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject stateObj) +346
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +3430
System.Data.SqlClient.SqlDataReader.ConsumeMetaDat a() +52
System.Data.SqlClient.SqlDataReader.get_MetaData() +130
System.Data.SqlClient.SqlCommand.FinishExecuteRead er(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +371
System.Data.SqlClient.SqlCommand.RunExecuteReaderT ds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +1272
System.Data.SqlClient.SqlCommand.RunExecuteReader( CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +334
System.Data.SqlClient.SqlCommand.RunExecuteReader( CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +45
System.Data.SqlClient.SqlCommand.ExecuteReader(Com mandBehavior behavior, String method) +162
System.Data.SqlClient.SqlCommand.ExecuteReader() +114
ASP.administration_orderallocation_aspx.ViewDestin ationBtn_Click(Object sender, EventArgs e) in c:\System\Administration\OrderAllocation.aspx:33
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +96
System.Web.UI.WebControls.Button.RaisePostBackEven t(String eventArgument) +116
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +31
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +32
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +72
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3824
|
|

March 21st, 2008, 11:42 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
Ok... it looks like this might be a very simple issue. The word "ORDER" is a keyword in sql. You are using it for a table name. The exception is telling us that the problem is a sql query issue, specifically the "Incorrect syntax near the keyword 'Order'." Try wrapping Order in square brackets which will tell SQL server that you mean an object named "Order", not the "Order" keyword.
comm = new SqlCommand(
"SELECT Destination FROM [Order] " +
"WHERE OrderID = @OrderID", conn);
-Peter
peterlanoie.blog
|
|

March 21st, 2008, 11:48 AM
|
|
Authorized User
|
|
Join Date: Mar 2008
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks, it works. :D In the back of my mind I thought about the [] between the Order, but because my other page worked I thought it was not needed! Don't you just love programming  ! So thanks for your help, I'll try to get the nested statements in now, so that I can show both the order destination and the ship destination.
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| sql query question |
ldp101068 |
SQL Server 2000 |
6 |
December 3rd, 2007 03:41 PM |
| ASP / Sql question |
joebeem |
Classic ASP Basics |
0 |
August 28th, 2007 02:45 PM |
| A SQL question |
pankaj_daga |
Access |
5 |
December 5th, 2005 04:37 PM |
| Sql-question |
boson |
SQL Language |
2 |
July 3rd, 2004 06:39 AM |
| SQL question |
U.N.C.L.E. |
SQL Server 2000 |
3 |
October 10th, 2003 02:00 PM |
|
 |