Missing parameter error after running MySql query
Posted
by annelie
on Stack Overflow
See other posts from Stack Overflow
or by annelie
Published on 2010-04-23T08:57:18Z
Indexed on
2010/04/23
9:03 UTC
Read the original article
Hit count: 261
Hello,
I'm completely new to MySql and haven't used SqlDataSource with UpdateParameters before, so I'm probably missing something very obvious.
When trying to update a record, the update does happen but then throws an error saying "'id' parameter is missing at the statement". So the query works and the database gets updated as it should, but an error is thrown afterwards.
These are the update parameters:
<UpdateParameters>
<asp:Parameter Name="business_name" Type="string" Size="256" />
<asp:Parameter Name="addr_line_1" Type="string" Size="256" />
<asp:Parameter Name="addr_line_2" Type="string" Size="256" />
<asp:Parameter Name="addr_line_3" Type="string" Size="256" />
<asp:Parameter Name="postcode" Type="string" Size="32" />
<asp:Parameter Name="county" Type="string" Size="128" />
<asp:Parameter Name="town_city" Type="string" Size="256" />
<asp:Parameter Name="tl_url" Type="string" Size="256" />
<asp:Parameter Name="customer_id" Type="string" Size="16" />
<asp:Parameter Name="region_id" Type="Int16" />
<asp:Parameter Name="description" Type="string" Size="1024" />
<asp:Parameter Name="approval_status" Type="string" Size="1" />
<asp:Parameter Name="tl_user_name" Type="string" Size="256" />
<asp:Parameter Name="phone" Type="string" Size="50" />
<asp:Parameter Name="uploaders_own" Type="Int16" />
</UpdateParameters>
Here's the update statement:
UPDATE myTable SET business_name = ?, addr_line_1 = ?, addr_line_2 = ?, addr_line_3 = ?, postcode = ?, county = ?, town_city = ?, tl_url = ?, customer_id = ?, region_id = ?, description = ?, approval_status = ?, tl_user_name = ?, phone = ?, uploaders_own = ? WHERE id = " + id
Here's the stack trace:
[InvalidOperationException: 'id' parameter is missing at the statement]
CoreLab.MySql.r.a() +775
CoreLab.MySql.r.a(Int32& A_0, ArrayList& A_1) +448
CoreLab.MySql.x.e() +398
CoreLab.MySql.x.o() +89
CoreLab.MySql.MySqlCommand.a(CommandBehavior A_0, IDisposable A_1, Int32 A_2, Int32 A_3) +1306
CoreLab.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior) +310
System.Data.Common.DbCommand.ExecuteReader() +12
CoreLab.Common.DbCommandBase.ExecuteNonQuery() +64
System.Web.UI.WebControls.SqlDataSourceView.ExecuteDbCommand(DbCommand command, DataSourceOperation operation) +386
System.Web.UI.WebControls.SqlDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +325
System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) +92
System.Web.UI.WebControls.DetailsView.HandleUpdate(String commandArg, Boolean causesValidation) +837
System.Web.UI.WebControls.DetailsView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +509
System.Web.UI.WebControls.DetailsView.OnBubbleEvent(Object source, EventArgs e) +95
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
System.Web.UI.WebControls.DetailsViewRow.OnBubbleEvent(Object source, EventArgs e) +113
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +118
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +135
System.Web.UI.WebControls.LinkButton.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) +175
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
Does anyone know what I'm doing wrong?
Thanks,
Annelie
© Stack Overflow or respective owner