Access database query using GUID key RRS feed

  • Question


    I have Access 2003. I need to write a C# app to import the contents of a (very simple) Access 2000 database. In this database are three tables, linked by primary keys. The keys have the datatype of 'number', but when I look at them in Access 2003, they are GUIDs. I can't work out how to write the SQL to get the records associated with a GUID. Based on some reading, I tried this:

    OleDbCommand cmd = Myconnection.CreateCommand();
    cmd.CommandText = "SELECT * FROM Records where Key = {GUID {" + clientKey + "}}";
    dbReader = cmd.ExecuteReader();

    but the reader is always empty. What's the syntax for filtering on a number data type that turns out to be a guid ?

    Monday, November 5, 2007 8:52 PM