Hiiiii!!
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?
plzzzzzzz....
Thanking You!!!
Hiiiii!!
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?
plzzzzzzz....
Thanking You!!!
I assume you have already figured this out on your own ?
You may use ExecuteScalar();
example:
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...
:)
try{
con.Open();
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();
}
}
catch
{
Result.Text = "THE GIVEN ID IS UNAVAILABLE";
}
finally
{
con.Close();
}
ThankX Buddy it works,,,,
but how to use it in Text Changed event of textbox......
????
will really appreciate if u get it???
bye...
bsr990.
I'm glad you got it helpful. If you want to ask question, start your own thread.
Thread Closed.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.