Can any one help me, how to retrieve information of employee in text boxes if i enter employee number in c# using data adapter and also why we use data adapter?


Thanking You!!!

Recommended Answers

All 5 Replies

I assume you have already figured this out on your own ?

You may use ExecuteScalar();

SqlCommand cmd = new SqlCommand("select Count(*) as Total from Customers",connect);

textBox1.Text = cmd.ExecuteScalar().ToString();

That all.

Try this and see... U'll Get the result...

                cmd = new SqlCommand("Select Employee_Name,Designation,Salary,Department,DateOfJoining,DateOfBirth,Qualification from EmployeeDetails where Employee_Id=@aa", con);
                cmd.Parameters.Add("@aa", SqlDbType.Int).Value = textBox1.Text;
                dr = cmd.ExecuteReader();
                if (dr.HasRows == false)
                    throw new Exception();   
                if (dr.Read())
                    // textBox1.Text = dr[0].ToString(); Since U r going to give the ID and retrieve in textBox1.
                    textBox2.Text = dr[0].ToString();
                    textBox3.Text = dr[1].ToString();
                    textBox4.Text = dr[2].ToString();
                    textBox7.Text = dr[3].ToString();
                    dateTimePicker1.Text = dr[4].ToString();
                    dateTimePicker2.Text = dr[5].ToString();
                    textBox5.Text = dr[6].ToString();
                Result.Text = "THE GIVEN ID IS UNAVAILABLE";
commented: it was useful for me... +0

ThankX Buddy it works,,,,
but how to use it in Text Changed event of textbox......
will really appreciate if u get it???


I'm glad you got it helpful. If you want to ask question, start your own thread.

Thread Closed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.