TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Chiranjeevi Aripaka
NA
133
304.1k
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();
Reply
Answers (
6
)
inserting textbox in gridview in asp using c#
Problem with filling the dataset with OleDBDataAdapter