Extremely simple SQLite query does not return expected

Below I provide my database schema, the database data that is currently inserted (this is only one entry), and the code I'm running. This is a very simple setup, but instead of returning a single record in the database, it returns nothing. Can anyone understand why? I am here at my end ...

Subcontractor table

Columns: listed below in format (name type).

ID guid, 
BusinessName varchar(50), 
Address varchar(200), 
City varchar(50), 
State varchar(50), 
ZipCode varchar(50), 
Contact varchar(50), 
Phone varchar(50), 
Fax varchar(50), 
Email varchar(200), 
GLOPolicy bit, 
GLOLimit bigint, 
GLOExpiration datetime, 
ALPolicy bit, 
ALLimit bigint, 
ALExpiration datetime, 
WCPolicy bit, 
WCLimit bigint, 
WCExpiration datetime, 
ULPolicy bit, 
ULLimit bigint, 
ULExpiration datetime, 
Notes varchar(15000)

=====

I have one entry in my database as shown below.

ID "7b143c19-ad66-46ad-b587-db0bee98cf1e"
BusinessName "1"
Address "1"
City "1"
State "1"
ZipCode "1"
Contact NULL
Phone NULL
Fax NULL 
Email NULL
GLOPolicy False (0) 
GLOLimit NULL 
GLOExpiration NULL
ALPolicy False (0)
ALLimit NULL
ALExpiration NULL
WCPolicy False (0)
WCLimit NULL
WCExpiration NULL
ULPolicy False (0) 
ULLimit NULL
ULExpiration NULL
Notes NULL

===== * * I am trying to execute the following query, and it does not return anything when it should explicitly return the single record shown above. *

String ID = "7b143c19-ad66-46ad-b587-db0bee98cf1e";
DataTable dt = sqliteQuery.selectFromDatabase("*", "WHERE ID = '" + ID + "'");

And the code for the above method ...

    public DataTable selectFromDatabase(String column, String filter)
    {
        string SQL = "SELECT " + column + " FROM SUBCONTRACTOR " + filter;
        SQLiteCommand cmd = new SQLiteCommand(SQL);
        cmd.Connection = connection;
        SQLiteDataAdapter da = new SQLiteDataAdapter(cmd);
        DataSet ds = new DataSet();
        try
        {
            da.Fill(ds);
            DataTable dt = ds.Tables[0];
            return dt;
        }
        catch (Exception e)
        {
            MessageBox.Show(e.ToString());
            return null;
        }
        finally
        {
            cmd.Dispose();
            connection.Close();
        }
    }
+3
1

, SqLite GUID . , , , . , TEXT. .

GUID pkey:

Guid.NewGuid().ToString();

, :

GUID (!) SQLite- , . , "BinaryGUID = Yes | No", Yes as . "BinaryGUID = Yes" GUID 16 . , "SQLite Expert" GUID . , , . , , (, ). , SQLite .

"BinaryGUID = ", GUID , 32-38 (I , {} , ). , . DB .

, .

+4

Source: https://habr.com/ru/post/1781085/


All Articles