我在 gridview 中有一个按钮字段,当我按下该按钮时,它从第一列获取 id 值,我在 select 语句中使用该 id 从表中获取数据,但我收到此错误“No Value Give For One或更多参数”
protected void grdData_SelectedIndexChanged(object sender, EventArgs e)
{
GridViewRow row = grdData.SelectedRow;
string id = row.Cells[1].Text;
try
{
conn.ConnectionString = conn_string;
conn.Open();
mySQLCommand.Connection = conn;
mySQLCommand.CommandText = "Select [Movie_Description],[Movie_Image] from Movie_tbl where Movie_ID = @Movie_ID";
mySQLCommand.Parameters.Add("@Movie_ID", OleDbType.VarChar).Value = id;
myDataReader = mySQLCommand.ExecuteReader();
if (myDataReader.Read())
{
txtDescription.Text = myDataReader["Movie_Description"].ToString();
}
else
{
txtDescription.Text = "No Such Movie";
}
}
catch (Exception ex)
{
throw ex ;
}
}