Parameterized Query
Hej Alle,Jeg kæmper med at få ASP.NET til at update i min sql database.
Her er koden:
Dim comm As New SqlCommand("UPDATE sider SET indhold='@fckeditoroutput' WHERE ID=@side", conn)
comm.Parameters.AddWithValue("@side", Request.Headers("side"))
Try
conn.Open()
Catch ex As Exception
TextBox1.Text = "Fejl i sql statements"
Finally
'TextBox1.Text = "Nu er den fin"
comm.ExecuteNonQuery()
conn.Close()
End Try
Og her er fejlen, Jeg kan ikke rigtigt se mig ud af hvad jeg gør galt.
[SqlException (0x80131904): Parameterized Query '(@side nvarchar(4000))UPDATE sider SET indhold='@fckeditoroutput' expects parameter @side, which was not supplied.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +857450
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +735062
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1838
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +149
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +886
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +132
System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +415
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +135
admin.Button1_Click(Object sender, EventArgs e) in D:\Data\Websites\smiszek.dk\admin.aspx.vb:34
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102