title: Must declare the scalar variable @firstname
body: <p>I am using parameterised query but I got an error - how can I solve it?</p>
  
  <p>Here is my code </p>
  
  <pre><code>SqlCommand cmd = new SqlCommand();
  string sql = @"insert into Student_Records (FirstName,LastName,Email,ContactNumber,DOB,TemporaryAddress,PermanentAddress,FatherName,Fathersoccupation,ContactNumberF,MotherName,Mothersoccupation,ContactNumberM,Remarks) values(@firstname,@lastname,@email,@contactnumber,@dob,@temporaryaddress,@permanentaddress,@fathername,@fatheroccupation,@contactnumberf,@mothername,@motheroccupation,@contactnumberm,@remarks) ";
  cmd.Parameters.AddWithValue("@firstname", txtFname.Text);
  cmd.Parameters.AddWithValue("@lastname", txtlastN.Text);
  cmd.Parameters.AddWithValue("@contactnumber", txtCN.Text);
  cmd.Parameters.AddWithValue("@dob", dtdob.Value);
  cmd.Parameters.AddWithValue("@temporaryaddress", txtTaddress.Text);
  cmd.Parameters.AddWithValue("@permanentaddress", txtPaddress.Text);
  cmd.Parameters.AddWithValue("@fathername", txtFname.Text);
  cmd.Parameters.AddWithValue("@fatheroccupation", txtFoccupation.Text);
  cmd.Parameters.AddWithValue("@contactnumberf", txtFcn.Text);
  cmd.Parameters.AddWithValue("@mothername", txtMname.Text);
  cmd.Parameters.AddWithValue("@motheroccoupation", txtMoccupation.Text);
  cmd.Parameters.AddWithValue("@contactnumberm", txtMcn);
  cmd.Parameters.AddWithValue("@remarks", rtremarks.Text);
  DBconnection.ExecutiveNonQuery(sql);
  </code></pre>
  
  <p>I get this error:</p>
  
  <blockquote>
    <p>must declare the scalar variable</p>
  </blockquote>