locked
Update with Where statement in Querystring RRS feed

  • Question

  • User-1020726294 posted

    Hi all,

    Hope someone can help. I have spent hours trial and error on this studpid statement. I have done this before with an Insert statement and that took many hours. Now I have lost all patience and need help with the Update.

    I have been looking at the query string in debug and it does not look right and it is not updating. If I try to put "  " around the values I get newline in constant error.

    Here is the code as of now:

     

    public void update_profile()
      {
        string myConnectionString = null;
        string uname = Membership.GetUser().UserName;
       string apost = "\"";
       string tbdate = DateTime.Now.ToString();
       //set up connection for Update
       OleDbConnection conn = new OleDbConnection("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = " + Context.Server.MapPath("access_db\\") + "potluckgals.mdb" + ";");
       conn.Open();
       string querystring = "UPDATE user_profile SET user_profile.filename = FileUpload1.PostedFile.FileName), user_profile.file_upload_date = tbdate  WHERE ((user_profile.user_login)= uname))";
       OleDbCommand comm=new OleDbCommand (querystring, conn);   
         comm.Connection = conn;  
        try
        {
         comm.ExecuteNonQuery();    
        }
       
        catch (Exception ex)
       {
        Console.WriteLine("Errors " + ex.GetBaseException().ToString());
       }


        comm.Connection.Close();
      }

     

    Sunday, October 9, 2011 9:55 AM

Answers

All replies