Hi Guys,
This is my first time using SQLite and I've run into an issue.
I've got a SQLlite Database keeping a list of people and associated
cost centres, it's pretty basic:
Two tables, both with an ID column which is unique, autoincrement and
primary key. Some other various columns, name, costcentre, email etc.
Most of which are set to not null. Nothing overly complex, it's very
basic. People have a cost centre and I'd join the two tables on
CostCentre.
I run this query:
SELECT * FROM PEOPLE left JOIN (COSTCENTRES ON PEOPLE.COSTCENTRE = COSTCENTRES.COSTCENTRE) where wipenabled = 1
It runs fine in the designer in VS and in SQLiteAdministrator, but when I run it in code it fails:
System.Data.ConstraintException: Failed to enable constraints. One or
more rows contain values violating non-null, unique, or foreign-key
constraints.
The code is:
using (SQLiteConnection conn = new SQLiteConnection(@"Data Source=" + path))
{
conn.Open();
SQLiteCommand cmd = new SQLiteCommand();
cmd.CommandType = CommandType.Text;
cmd.Connection = conn;
cmd.CommandText = sql;
SQLiteDataReader dr = cmd.ExecuteReader();
dt.Load(dr);
dr.Close();
conn.Close();
}
Does anyone have any idea where I'm going wrong here? I've checked the
DB and not ever turned constraints on, so I don't think it's that - The
query seems okay as it runs in SQLiteAdmin. I'm inserting into a new DataTable Object, which as far as I know has no constraints.
any help appreciated!