Chiranjeevi Aripaka

Chiranjeevi Aripaka

  • NA
  • 133
  • 303.4k

Please help in fixing this compliation error

Nov 30 2011 5:09 AM


hi frnds,

 please help me in sorting out this error....

i have a databse table with name STUDENT.  and the fields are branch, address, attendance.

iam retrieving data based  on the REGDNO, which iam going to enter in textbox with id textbox8 as shown below.

after pressing submit button the details has to be displayed in the textboxes accordingly..

please enter regd no textbox8
branch textbox2
address textbox3
attendance textbox4


submit


========================================================
SqlConnection con = new SqlConnection(database.ConnectionString);
  con.Open();

  SqlCommand cmd = new SqlCommand("select BRANCH,ADDRESS,ATTENDANCE from STUDENT WHERE REGDNO='" + textBox8.Text + " '  ", con);

  SqlDataReader reader = cmd.ExecuteReader();

  if (reader.Read())
  {

  //while (reader.Read())
  //{
  //Assign to your textbox here 

 
  textBox2.Text = reader["BRANCH"].ToString();
  textBox3.Text = reader["ADDRESS"].ToString();
  textBox4.Text = reader["ATTENDANCE"].ToString();
  }
  //}
  reader.Close();
  con.Close();
=======================================================





Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0103: The name 'textBox8' does not exist in the current context

Source Error:


Line 27: con.Open();
Line 28:
Line 29: SqlCommand cmd = new SqlCommand("select STUDENT,BRANCH,ADDRESS,ATTENDANCE from STUDENT WHERE REGDNO='" + textBox8.Text + " ' ", con);
Line 30:
Line 31: SqlDataReader reader = cmd.ExecuteReader();


Answers (6)