private void TxtCariPelanggan_TextChanged(object sender, EventArgs e) { //membuat perintah cari pelangan berdasarkan kode atau nama SqlConnection conn = konn.GetConn(); cmd = new SqlCommand("select * from pelanggan where NamaPelanggan like '%" + TxtCariPelanggan.Text + "%' or KodePelanggan like '%" + TxtCariPelanggan.Text + "%'", conn); ds = new DataSet(); da = new SqlDataAdapter(cmd); da.Fill(ds, "pelanggan"); DataGridPelanggan.DataSource = ds; DataGridPelanggan.DataMember = "pelanggan"; DataGridPelanggan.Refresh(); conn.Close(); }
//prosedur refresh pelanggan void refresh_pelanggan() { SqlConnection conn = konn.GetConn(); try { conn.Open(); cmd = new SqlCommand("select * from pelanggan", conn); ds = new DataSet(); da = new SqlDataAdapter(cmd); da.Fill(ds, "pelanggan"); DataGridPelanggan.DataSource = ds; DataGridPelanggan.DataMember = "pelanggan"; DataGridPelanggan.Refresh(); } catch (Exception e) { MessageBox.Show(e.ToString()); } finally { conn.Close(); } }