下面語法無效
dbCommand.Parameters.AddWithValue("@parameter", value);
下面語法才能成功傳遞參數
dbCommand.Parameters.Add(new SQLiteParameter("@parameter"));
dbCommand.Parameters["@parameter"].Value = value;
dbCommand.Parameters["@parameter"].Value = value;
下面是一個 sample code
string SqlText = "Delete From Brand Where id=@id";
SQLiteCommand dbCmd = new SQLiteCommand(SqlText, _sCon);
dbCmd.Parameters.Add(new SQLiteParameter("@id"));
dbCmd.Parameters["@id"].Value = BrandID;
_sCon.Open();
dbCmd.ExecuteNonQuery();
_sCon.Close();
SQLiteCommand dbCmd = new SQLiteCommand(SqlText, _sCon);
dbCmd.Parameters.Add(new SQLiteParameter("@id"));
dbCmd.Parameters["@id"].Value = BrandID;
_sCon.Open();
dbCmd.ExecuteNonQuery();
_sCon.Close();