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
Usama Shaikh
NA
1
653
Retrieve related data through id in text boxes ?
Feb 25 2016 8:54 AM
i want to retrieve data into text boxes through id or name. im using this code:
public partial class Form3 : Form
{
string connStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlCommand com;
//SqlDataAdapter sqlda;
//DataSet ds;
string str;
private void button4_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.Open();
str = "select * from Department where Code='" + codeTextBox.Text.Trim() + "'";
com = new SqlCommand(str, con);
SqlDataReader reader = com.ExecuteReader();
if (reader.Read())
{
dep_NameTextBox.Text = reader["Name"].ToString();
dep_TypeTextBox.Text = reader["Dep_Type"].ToString();
//TextBox4.Text = reader["ADDRESS"].ToString();
//TextBox5.Text = reader["PHNO"].ToString();
//TextBox6.Text = reader["STATE"].ToString();
reader.Close();
con.Close();
}
When i run the program it generate the error:
An unhandled exception of type 'System.NullReferenceException' occurred in voucher.exe
Additional information: Object reference not set to an instance of an object.
how to resolve it?
or how to retrieve related id data in text boxes in other query ?
Reply
Answers (
1
)
No overload for method ' ' takes 8/11 arguments
Trouble to serialize XML with classes and a list