我尝试使用SQL查询获取数量,但它不起作用;
string selectrow;
int rowindex = dataGridView1.CurrentCell.RowIndex;
int columnindex = dataGridView1.CurrentCell.ColumnIndex;
selectrow = dataGridView1.Rows[rowindex].Cells[columnindex].Value.ToString();
string query = @"select quantite_pdt from produits where ref_pdt = @pp";
try
{
using (var conn = loaddatabaseconnexion.connexion_BDD())
using (var cmd = new SqlCommand(query, conn))
{
cmd.Parameters.AddWithValue("@pp", int.Parse(selectrow));
SqlCommand command = new SqlCommand(query, loaddatabaseconnexion.connexion_BDD());
string nbstr = command.ExecuteScalar().ToString();
}
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
我不明白,因为我的变量@pp被声明了。
ITMISS
相关分类