Why do I get the following error when clicking the ordrer button in my ASP .NET application?
`if cmd.ExecuteScalar = 1 then
`Server Error in '/BookShop' Application.
Line 1: Incorrect syntax near '='.
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: Line 1: Incorrect sy开发者_开发技巧ntax near '='.
Source Error:
Line 64: con.Open()
Line 65: Dim cmd As New SqlCommand(sql, con)
Line 66: If cmd.ExecuteScalar() Then
Line 67: Session("EntryNumber") = Val(TextBox2.Text)
Line 68: Response.Redirect("order.aspx")
Source File: D:\Review Material\DIPLOMA\DOTNET FULL PROJECTS\DPEE02\DPEE02\CODING\BookShop\BookDetails.aspx.vb Line: 66
Stack Trace:
[SqlException (0x80131904): Line 1: Incorrect syntax near '='.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +98
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +82
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +346
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +3430
System.Data.SqlClient.SqlDataReader.ConsumeMetaData() +52
System.Data.SqlClient.SqlDataReader.get_MetaData() +130
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +371
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(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.ExecuteScalar() +161
BookShop.BookDetails.Button2_Click(Object sender, EventArgs e) in D:\Review Material\DIPLOMA\DOTNET FULL PROJECTS\DPEE02\DPEE02\CODING\BookShop\BookDetails.aspx.vb:66
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +96
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +116
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +31
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +32
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +72
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3825
Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433
This is probably an error in the SQL that is being executed - the contents of the SQL variable. Can you post this please?
精彩评论