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
Amrul Hakim
NA
19
3.9k
How to Make Autocomplete from database sql?
May 18 2017 2:36 AM
This my code in class Fungsi
public
void
autocompele1(TextBox autotext)
{
conn = Koneksi.Conn;
conn.Open();
cmd =
new
SqlCommand(
"SELECT Nama_Barang FROM Tb_Barang ORDER BY Nama_Barang"
, conn);
try
{
Reader = cmd.ExecuteReader();
if
(Reader.HasRows)
{
while
(Reader.Read())
{
autotext.AutoCompleteCustomSource.Add(Reader[
"Nama_Barang"
].ToString());
}
}
else
{
MessageBox.Show(
"Data Not Found"
);
}
}
catch
(Exception ex)
{
MessageBox.Show(
"erorr"
+ ex.Message);
}
finally
{
conn.Close();
Reader.Close();
}
}
and i called in form like this
private
void
Form_Transaksi_Load(
object
sender, EventArgs e)
{
Fungsi auto =
new
Fungsi();
auto.autocompele1(txt_NamaBarang);
}
Reply
Answers (
4
)
datagrid number take 0 if i open new form
How to replace id in url with some title.