0

i have a buttonfield in a gridview, when i press that button it takes the id value from the first column, i use that id in a select statement, to get data from the table, but i get this error "No Value Give For One Or More Parameters"

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 ;
    }

}

1 Answers1

0

I haven't worked with mySQL much, but I'm pretty sure you don't want an OleDbType.VarChar parameter. I haven't seen that used outside of MS Access. Try:

mySQLCommand.Parameters.AddWithValue("@Movie_ID", id);

if that fails, maybe try

mySQLCommand.Parameters.Add(new MySqlParameter("@Movie_ID", id));

mySQLCommand is of type MySqlCommand in your code, right?

Kendall Trego
  • 1,975
  • 13
  • 21
  • I'm using access database i just called the oleDBCommand OleDbCommand mySQLCommand = new OleDbCommand(); –  Jan 20 '13 at 11:45