正如我寫的,我沒有設法使用參數方法更新我的SQLite數據庫。不要使用參數方法更新SQLite數據庫
下面是代碼:
using (SQLiteConnection cnn = new SQLiteConnection("Data Source=BarMalnate.sqlite;Version=3;"))
{
using (SQLiteCommand command = new SQLiteCommand("UPDATE Concorso SET Controlla = @Controlla WHERE Numero = @Numero", cnn))
{
//example variable
int num = 2;
int mynum = 2;
command.Parameters.AddRange(new SQLiteParameter[]
{
new SQLiteParameter("@Controlla", DbType.Int32){ Value = num},
new SQLiteParameter("@Numero", DbType.Int32){ Value = mynum}
});
cnn.Open();
command.ExecuteNonQuery();
}
}
問題在哪裏?你想說你發佈的代碼不起作用嗎? – dotNET
是的,我沒有錯誤,但數據庫沒有更新... – Peppegiuseppe