我用C# VS2013和SQLite数据库创建了一个小型桌面应用程序进行数据插入操作,该应用程序使用了[WinForm]。它能正常工作并且能够执行所有的CRUD操作。但是当我使用Advance Installer创建安装程序时,每当我运行该应用程序并尝试插入数据时,就会弹出此窗口:
谢谢。
这是一些代码片段。
//Add Property Function.
string ConnectionString = "Data Source=database/MyProperty.db;Version=3;Read Only=False";
public static long AddPropertyToDatabae( Property property )
{
SQLiteConnection con = new SQLiteConnection( ConnectionString );
SQLiteCommand cmd = new SQLiteCommand
{
Connection = con,
CommandText =
"INSERT INTO Properties (PropertyName,PropertyAddress,PropertyCity,PropertyState,PropertyZip,PropertyNotes)" +
" values (@Name,@Address,@City,@State,@Zip,@Notes)"
};
cmd.Parameters.AddWithValue( "@Name", property.PropertyName );
cmd.Parameters.AddWithValue( "@Address", property.PropertyAddress );
cmd.Parameters.AddWithValue( "@City", property.PropertyCity );
cmd.Parameters.AddWithValue( "@State", property.PropertyState );
cmd.Parameters.AddWithValue( "@Zip", property.PropertyZip );
cmd.Parameters.AddWithValue( "@Notes", property.PropertyNotes );
con.Open();
cmd.ExecuteNonQuery();
// Get the Last Inserted RowId.
cmd.CommandText = "select last_insert_rowid()";
long rowid = ( long )cmd.ExecuteScalar();
con.Close();
return rowid;
}
注意
这段代码在VS中是百分之百可行的,但是当我创建应用程序的安装文件时就会出现错误。