locked
need help on an access Query Error RRS feed

  • Question

  • User-973411778 posted

    Hello everyone,
    I have a problem with an update query using the Access control - detailsView, I want to update data in the database for a catalog product with the possibility of uploading images.

    Image uploading is done before carrying out general update of product data with a control FILEUPLOAD - image uploading and registering its name properly works without any problems.

    The problem start when I click the update button in the DetailsView control, after saving the new picture name by SESSION.

    the query format that includes the 2 (product name and picture) is:

    cmd.CommandText = string.Format("UPDATE [products] SET [cat_id] = @cat_id, [OldName] = @OldName ,[Name] = @Name,[Desc] = @Desc,[Resistance] = @Resistance,[Weight] = @Weight, [Indoor] = @Indoor,[Season] = @Season,[pic_small] = '{0}',[pic_big] = @pic_big,[zOrder] = @zOrder WHERE [Name]='{1}'", fileName, productName

    after committing The query the Error messge i get is:

    System.Data.OleDb.OleDbException was unhandled by user code
      Message=No value given for one or more required parameters.
      Source=Microsoft JET Database Engine
      ErrorCode=-2147217904
      StackTrace:
           at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
           at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
           at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
           at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
           at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
           at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
           at Xadmin.dlsProduct_ItemUpdating(Object sender, DetailsViewUpdateEventArgs e) in \\wpsbs2003\users\Asaf\My Documents\Visual Studio 2010\WebSites\EatCatalog\Xadmin.aspx.cs:line 117
           at System.Web.UI.WebControls.DetailsView.OnItemUpdating(DetailsViewUpdateEventArgs e)
           at System.Web.UI.WebControls.DetailsView.HandleUpdate(String commandArg, Boolean causesValidation)
           at System.Web.UI.WebControls.DetailsView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup)
           at System.Web.UI.WebControls.DetailsView.OnBubbleEvent(Object source, EventArgs e)
           at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
           at System.Web.UI.WebControls.DetailsViewRow.OnBubbleEvent(Object source, EventArgs e)
           at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
           at System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e)
           at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument)
           at System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
           at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
           at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
           at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
      InnerException

    Wednesday, July 7, 2010 4:10 AM

Answers

  • User-1199946673 posted

    Try replacing all of the @<field> markers with question marks (?).
     

    That won't help at all!

    Also make sure that each parameter in your SELECT statement has a valid value.

    Yes, and the parameters should be added in the same order they appear in the SQL statement.

    But I think the problem is with the 2 place holders {0} and {1} (at least I think they are place holders? Why aren't you using parameters for those values?

    Another reason for this error is when you mistype one or more field (or table) names. In that case, Access is treating these as parameters, which obviously, you don't provide a value for them....

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 7, 2010 2:32 PM
  • User1759999623 posted

    I've noticed something else with your query.  It appears that you are setting the [Name] (using @Name) in your UPDATE statement, but you are using the [Name] in your WHERE clause using the placeholder to pass in the value for the productName variable.  You need to verify if this is correct as you may be using two different values and that you may be updating a field that should not be changed. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 7, 2010 4:51 PM

All replies

  • User1759999623 posted

    Try replacing all of the @<field> markers with question marks (?). Also make sure that each parameter in your SELECT statement has a valid value. 

    Wednesday, July 7, 2010 10:46 AM
  • User-1199946673 posted

    Try replacing all of the @<field> markers with question marks (?).
     

    That won't help at all!

    Also make sure that each parameter in your SELECT statement has a valid value.

    Yes, and the parameters should be added in the same order they appear in the SQL statement.

    But I think the problem is with the 2 place holders {0} and {1} (at least I think they are place holders? Why aren't you using parameters for those values?

    Another reason for this error is when you mistype one or more field (or table) names. In that case, Access is treating these as parameters, which obviously, you don't provide a value for them....

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 7, 2010 2:32 PM
  • User1759999623 posted

    I've noticed something else with your query.  It appears that you are setting the [Name] (using @Name) in your UPDATE statement, but you are using the [Name] in your WHERE clause using the placeholder to pass in the value for the productName variable.  You need to verify if this is correct as you may be using two different values and that you may be updating a field that should not be changed. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 7, 2010 4:51 PM