Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Leonel
Starting Member
10 Posts |
Posted - 2012-06-17 : 13:18:11
|
this code populate the combobox, just finecode Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Database\ReturnEquipment.accdb;Persist Security Info=False;") Dim CMD1 As New OleDb.OleDbCommand CMD1.Connection = con con.Open() CMD1.CommandText = "SELECT SN from RMA" Dim miDataReader As OleDb.OleDbDataReader miDataReader = CMD1.ExecuteReader Dim dt As New DataTable dt.Load(miDataReader) ComboBox1.DataSource = dt ComboBox1.ValueMember = dt.Columns(0).ToString() ComboBox1.DisplayMember = dt.Columns(0).ToString() con.Close()I want to populae the datagridbview based on the selected value of the comboboxmy datagridview is called dgDetailsi tried differents ways and no luckany help |
|
Leonel
Starting Member
10 Posts |
Posted - 2012-06-20 : 21:48:58
|
Dim conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Database\ReturnEquipment.accdb;Persist Security Info=False;") Dim myCommand = New OleDbCommand("select * from RMA WHERE SN = @SN") myCommand.Connection = conn conn.Open() myCommand.Parameters.AddWithValue("@sn", ComboBox1.SelectedValue) Dim ds As Data.DataSet = New Data.DataSet Dim dr As OleDbDataReader Dim DA As New OleDbDataAdapter dr = myCommand.ExecuteReader myCommand.Connection = conn DA.Fill(ds, "RMA") DataGridView1.DataSource = ds myCommand.dispose() con.Close() End Subi used this code and i get this error:The SelectCommand property has not been initialized before calling 'Fill'. |
|
|
|
|
|