none
MS Access, Update, Guid RRS feed

  • Question

  • During executing Update query on MS Access I am found a interesting thing
    This query works: "UPDATE [table] SET [boolfield] = False WHERE [id] = '{" + id + "}'"
    And this - not work: "UPDATE [table] SET [boolfield] = False WHERE [id] = '" + id + "'"
    Field [id] - GUID (replication code).

    Question: Why if a make SELECT or INSERT query - all works without { } symbols, but on UPDATE - OLEDB engine need it?
    Friday, December 28, 2007 11:12 AM

All replies

  • YOu can either use the "native" string represenation of the GUID (those with the brackets) or Cast the appropiate string to a GUID using the CAST or CONVERT statement.

    Jens K. Suessmeyer


    ---
    http://www.sqlserver2005.de
    ---

    Saturday, January 5, 2008 3:57 PM
  • Code Snippet

        public static bool Rename(Guid category_id, string category_name)
        {
          using (OleDbConnection connection = new OleDbConnection(Constants.ConnectionString))
          {
            OleDbCommand command = new OleDbCommand("UPDATE Category SET Category_Name = '" + category_name + "' WHERE Category_ID = '{" + category_id + "}'", connection);
    ..........................
    }}


    See? Guid sending as native. And anyway i need brackets =(
    Tuesday, February 19, 2008 12:44 PM