I need your kind help.
I am basically wanting to filter the data from SQL server database via VB.NET combo box to data grid view, make changes and then save them back to the database.
The thing is i am not being able to filter the data via the combobox
My code may be wrong or mistaken, for which I need your help.
Please reply
I am basically wanting to filter the data from SQL server database via VB.NET combo box to data grid view, make changes and then save them back to the database.
The thing is i am not being able to filter the data via the combobox
Code:
"Imports System.Data Imports System.Console Imports System.Data.SqlClient Imports System.Data.OleDb Public Class Form1 Dim sqlcon As New SqlConnection Dim ds As New DataSet Dim dc As SqlCommand Dim daa As New SqlDataAdapter Dim bs As New BindingSource 'Public Const ConnectionString As String = "Data Source=SQLORACLE;Initial Catalog=greeting;User ID=classic;password=stripes" Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'TODO: This line of code loads data into the 'GreetingDataSet.db1' table. You can move, or remove it, as needed. Me.Db1TableAdapter.Fill(Me.GreetingDataSet.db1) cboest.Sorted = True cboest.Enabled = False cbover.Enabled = False Db1DataGridView.Visible = False Db1BindingNavigator.Visible = False End Sub Private Sub Db1BindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Db1BindingNavigatorSaveItem.Click Me.Validate() Me.Db1BindingSource.EndEdit() Me.Db1TableAdapter.Update(Me.GreetingDataSet.db1) End Sub Private Sub cmdselect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdselect.Click // filtering the according to "estno" Dim cbostr cbostr = Me.cboest.Text Dim dv As DataView dv = ds.Tables("db1").DefaultView dv.RowFilter = "estno like = " & cbostr cboest.Enabled = True cmdselect.Enabled = False End Sub Private Sub cboest_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboest.SelectedIndexChanged cbover.Enabled = True End Sub Private Sub cbover_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbover.SelectedIndexChanged cboest.Enabled = False cbover.Enabled = False cmdselect.Enabled = True Db1DataGridView.Visible = True Db1BindingNavigator.Visible = True End Sub End Class"
My code may be wrong or mistaken, for which I need your help.
Please reply
Comment