Try
Dim dv As New DataView(dtable)
dv.RowFilter = String.Format("fname like '%{0}%'", TextBox9.Text)
DataGridView1.DataSource = dv
Catch ex As Exception
MessageBox.Show(ex.Message, "filter")
End Try
Free Download Sample VB.Net Apps and its Data Source Code
Monday, July 4, 2016
Fill ComboBox ; SQL Server ; VB.NET
Try
myconn = New SqlConnection(My.Settings.testsettings)
myconn.Open()
mycmd = New SqlCommand("select * from test1", myconn)
dr = mycmd.ExecuteReader
While dr.Read
ComboBox1.Items.Add(dr("fname"))
End While
Catch ex As Exception
MessageBox.Show(ex.Message, "cbox")
End Try
myconn.Close()
mycmd.Dispose()
dr.Close()
myconn = New SqlConnection(My.Settings.testsettings)
myconn.Open()
mycmd = New SqlCommand("select * from test1", myconn)
dr = mycmd.ExecuteReader
While dr.Read
ComboBox1.Items.Add(dr("fname"))
End While
Catch ex As Exception
MessageBox.Show(ex.Message, "cbox")
End Try
myconn.Close()
mycmd.Dispose()
dr.Close()
Search from DataGridView VB.NET
Dim i As Integer = 0
Dim rcount As Integer = 0
Dim ifound As Boolean = False
Try
rcount = DataGridView1.RowCount
DataGridView1.MultiSelect = False
While i < rcount And ifound = False
DataGridView1.Rows(i).Selected = True
If DataGridView1.SelectedRows(0).Cells(1).Value = TextBox10.Text Then
DataGridView1.CurrentCell = DataGridView1(0, i)
ifound = True
else
i = i + 1
End If
End While
Catch ex As Exception
MessageBox.Show(ex.Message, "found")
End Try
If ifound = False Then MessageBox.Show("no record found", "")
Dim rcount As Integer = 0
Dim ifound As Boolean = False
Try
rcount = DataGridView1.RowCount
DataGridView1.MultiSelect = False
While i < rcount And ifound = False
DataGridView1.Rows(i).Selected = True
If DataGridView1.SelectedRows(0).Cells(1).Value = TextBox10.Text Then
DataGridView1.CurrentCell = DataGridView1(0, i)
ifound = True
else
i = i + 1
End If
End While
Catch ex As Exception
MessageBox.Show(ex.Message, "found")
End Try
If ifound = False Then MessageBox.Show("no record found", "")
Subscribe to:
Posts (Atom)