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
MOHSEN BENAISSA
NA
23
5.5k
use Textbox to display datatable
Oct 16 2018 5:04 AM
Hi friend's
how can i use textbox(primary key in my datatable) whene i write a number all the other informations can display in the windows form
exp :
if i put number "1" in textbox---> code client
the other textbox display (Name, adress, tel....)
this is my database
Reply
Answers (
1
)
1
Suraj Kumar
0
9.9k
2.2m
Oct 16 2018 5:09 AM
Hello,
try this, some modification needed. Write this code on Text Changed event of textbox.
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();
}
How to show databound drop down list in a column of DGV?
Check the items in checkedlistbox while updating using datab