i keep getting this error "Must declare the scalar variable"

abdelrahman mostafa 1 Reputation point
2022-11-10T11:23:06.57+00:00

//>>>>> this is the connection to sql

public partial class Form1 : Form
{

    OleDbConnection con_sql = new OleDbConnection("Provider = sqloledb; Server=IT1038-109\\SQL_ABDELRAHMAN;Database=nana_db;Trusted_Connection=yes;");  

//>>>>> this is the error button

private void button5_Click(object sender, EventArgs e)
{

        con_sql.Open();  
        OleDbCommand cmd1 = con_sql.CreateCommand();  

          

        cmd1.CommandText = "select id,name,job,salary from info where id=@drr ";  

//>>>>>>>>>>>>>>problem here
cmd1.Parameters.AddWithValue("@DRR ", textbox7.text);

        OleDbDataReader reader5;  
        reader5 = cmd1.ExecuteReader();  

        if (reader5.Read())  
        {  
            textBox3.Text = reader5["id"].ToString();  
            textBox4.Text = reader5["name"].ToString();  
            textBox5.Text = reader5["job"].ToString();  
            textBox6.Text = reader5["salary"].ToString();  
        }  
        else  
        {  
            MessageBox.Show("wait ..");  
        }  

        MessageBox.Show("Record Submitted", "Congrats");  
        con.Close();  
    }  
Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,865 questions
{count} votes