In my project I am using System.Data.Sqlite. I want to create a table with image column. I am setting default image (i.e. NoImageAvailable). But it gives me error i.e. SQL logic error or missing database near "@img": syntax error. Here is my code.
byte[] img = null;
try
{
img = File.ReadAllBytes(Application.StartupPath +
@"\Resources\General_Images\NOPHOTO.jpg");
}
catch { }
string qry = "CREATE TABLE [CLIENT_MSTR] " +
"([ID] INTEGER IDENTITY," +
"[CLIENT_ID] INTEGER PRIMARY KEY," +
"[ABBR] VARCHAR(3) DEFAULT '" + string.Empty + "' UNIQUE," +
"[PHOTO] BLOB DEFAULT @img)";
SQLiteCommand cmd = new SQLiteCommand(qry, m_dbConnection);
cmd.Prepare();
cmd.Parameters.Add("@img", DbType.Binary, img.Length);
cmd.Parameters["@img"].Value = img;
try
{
cmd.ExecuteNonQuery();
}
catch { }
What is wrong?