0

我正在嘗試使這項工作完成一項任務,而且我似乎無法弄清楚什麼是錯誤的。我正在Visual Studio 2012中創建Web應用程序。當我嘗試將表單發佈到數據庫時出現此錯誤。我是一個完全noob,這是我第一次在這裏發佈,所以請忍受我。我檢查了列名拼寫,一切似乎都是按順序排列的。'/'應用程序中的服務器錯誤。 ')'附近的語法不正確

Server Error in '/genericname' Application. 
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: Incorrect syntax near ')'. 

源錯誤:

Line 18:   myCom.Parameters.AddWithValue("@fullText", txtFullText.Text) 
Line 19:   myCon.Open() 
Line 20:   myCom.ExecuteNonQuery() 
Line 21:   myCon.Close() 
Line 22: 
Source File: F:\Documents\School\WebAppDevelopment\Assignment1\****\admin\add-article.aspx.vb Line: 20 

堆棧跟蹤:

[SqlException (0x80131904): Incorrect syntax near ')'.] 
    System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +1754082 
    System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +5295874 
    System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +242 
    System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +1682 
    System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +269 
    System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite) +1325 
    System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite) +175 
    System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite) +205 
    System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +160 
    admin_add_article.btnSave_Click(Object sender, EventArgs e) in F:\Documents\School\WebAppDevelopment\Assignment1\CarlsonDavidLab2\admin\add-article.aspx.vb:20 
    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9634378 
    System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +103 
    System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35 
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724 

這裏是我的代碼:

enter image description here 任何幫助表示讚賞。謝謝!

+0

您有一個額外的'''在後subDate'。 –

+0

@FelixPamittan,鷹眼...... LOL – Rahul

回答

1

你必須在該行的subDate後進行額外的,

mySQL &= "summary, fullText, subDate,) VALUES (@headline, @postDate, @author, @category, " 

補充說明,而不是使用AddWithValue,你應該使用Parameters.Add並指定底層數據庫的數據類型。

更多關於此here.

+1

先生,你是凡人中的冠軍,而StackOverflow是蜜蜂的膝蓋。 – sneakily04

相關問題