0
在我的項目中,我使用的是System.Data.Sqlite
。我想創建一個包含圖像列的表格。我設置了默認圖像(即NoImageAvailable)。但它給了我錯誤,即SQL logic error or missing database near "@img": syntax error
。這是我的代碼。在Sqlite數據庫中將默認圖像設置爲列
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 { }
什麼是錯?