Hello..
I have a form and i have used a combobox along with datagridview and textbox..
I have various values in combobox namely Mechanical, Electrical, Etectronics etc..
When I select the option Mechanics, I wish only few fields of the table be updated in the gridview, with the type mechanics. The Code i have used is :
Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
Try
'MsgBox("Open")
cn = New OleDbConnection("Provider=microsoft.jet.oledb.4.0;Data Source=E:\Project-Hemtech\HemDatabase1.mdb;")
cn.Open()
cmd = New OleDbCommand("select partname,partdesc,partnum,partqty from partno where type='" & ComboBox2.Text & "'", cn)
cmd.ExecuteNonQuery()
HemDatabase1DataSet2.Reset()
Me.PartnoTableAdapter2.Fill(Me.HemDatabase1DataSet2.partno)
dataGridView1.DataSource = Me.HemDatabase1DataSet2.partno
MsgBox("Your Account Created Successfully ")
'MsgBox("Done !!")
Catch myException As Exception
MsgBox("No Record Inserted" + myException.ToString())
Finally
'MsgBox("Closing Connection")
cn.Close()
End Try
End Sub
Now, the problems I am facing are :
I am getting all the fields, instead of the specified ones in the query, in the grid view.
Also, the where clause, is not being executed ie. It gives the entire database as it is.
The database in the gridview does not get updated. It keeps giving me the old databse, even after updation, unless I Bind it again, with the data source.
I am completely new to the concept of Datagridview and combobox as making the project for first time in vb.net.. Please Help me !!
Thank You.