Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
4
Reply
How to Make Autocomplete from database sql?
Amrul Hakim
May 18 2017 2:36 AM
190
Reply
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);
}
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
4
)
Next Recommended Forum
datagrid number take 0 if i open new form
How to replace id in url with some title.