c# Mysql如何正确使用AND和Where子句



这是我的代码

int indextest = 0;

MySqlConnection connection = new MySqlConnection(MyConString);
connection.Open();
MySqlCommand cmd = new MySqlCommand();

cmd.CommandText = "Select backup,Client,No_Projet,Description from historique Where id= @dataID and index= @indexID";
cmd.Parameters.AddWithValue("@dataID", soumissionId.Text);
cmd.Parameters.AddWithValue("@indexID", indextest);
cmd.Connection = connection;
MySqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())

不能计算如何格式我的字符串形式有和工作。我总是在index= 0附近出错

有谁能帮我一下吗

我的SQL使用'字符来包含名称,您可以在查询中使用它们:

cmd.CommandText = "Select `backup`,`Client`,`No_Projet`,`Description` from `historique` Where `id` = @dataID and `index` = @indexID";

最新更新