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
q w
NA
1
1.3k
How to AutoFill 2nd TextBox according to 1st TextBox from DB
Feb 7 2015 2:16 PM
lbouly overHow to AutoFill second TextBox according to first TextBox with the corresponding data in the DataBase
there's a datatable with 2 column, 1st one is studentname & 2nd column is StudentAverage.
First txtbx is autosuggest(studentname). How to make the second txtbx automaticaly fill according to 1st txtbx (2nd txtbx fill with the corresponding record of second column (studentsavrage)?
i mean, when i write someone's name in the first txtbox, the second txtbx automatically fills & shows its corresponding data(avrage)
this is for the 1st txtbx; it shows StudentNames
private
void
txtbxName_TextChanged
(
object
sender
,
EventArgs
e
)
{
AutoCompleteStringCollection
namesCollection
=
new
AutoCompleteStringCollection
();
string
StrCmd
=
"SELECT * FROM School"
;
string
ConnStr
=
@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\School_Database.accdb"
;
OleDbConnection
MyConn
=
new
OleDbConnection
(
ConnStr
);
MyConn
.
Open
();
OleDbCommand
Cmd
=
new
OleDbCommand
(
StrCmd
,
MyConn
);
OleDbDataReader
ObjReader
=
Cmd
.
ExecuteReader
();
if
(
ObjReader
!=
null
)
{
while
(
ObjReader
.
Read
())
namesCollection
.
Add
(
ObjReader
[
"StudentName"
].
ToString
());
}
else
{
MessageBox
.
Show
(
"Data not found"
);
}
ObjReader
.
Close
();
MyConn
.
Close
();
txtbxName
.
AutoCompleteMode
=
AutoCompleteMode
.
Suggest
;
txtbxName
.
AutoCompleteSource
=
AutoCompleteSource
.
CustomSource
;
txtbxName
.
AutoCompleteCustomSource
=
namesCollection
;
}
Reply
Answers (
0
)
List<T> and Collection in c#
How to get or set a frame using taglib# in mp3