0

this code works but it doesnot display multiple records.. like
if i search for Andrew, i want my code to display all names similar to
Andrew,
Alex,
Adam..etc
can anyone please help me with the code. Mu code is listed below. thanks

Private Sub Find_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim dtsr As DataTable
        Dim search As String
        search = Form1.txtsearch1.Text
        Dim da As OleDb.OleDbDataAdapter
        da = New OleDb.OleDbDataAdapter("Select * from Application Where Name LIKE'" & Trim(Form1.txtsearch1.Text) & "'", "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=J:\Alumni\Alumni\Alumni\aadb.mdb")
        dtsr = New DataTable
        da.Fill(dtsr)
        DataGridView1.DataSource = dtsr

    End Sub
3
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by finito
0

huummm your code is write but there is only two three mistakes. Try this one for searching purpose.

Private Sub Find_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
''open the connection
dim str as String
dim ds as Dataset
Dim da as SqlDataAdapter
str="Select * from [Application] Where [Name] LIKE' " & Trim(Form1.txtsearch1.Text) & " ' ; "
 
        ds = New DataSet
        da = New SqlDataAdapter(str, con) '''Con is connection string pass your ''connection
        da.Fill(ds, "Application")
        DataGridView1.DataSource = ds
        DataGridView1.DataMember = "Application"

end sub
0

Andrew,
Alex,
Adam..etc

How is Alex similar to Andrew?
starts with A?
please explain what you mean by similar

0

huummm your code is write but there is only two three mistakes. Try this one for searching purpose.

Private Sub Find_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
''open the connection
dim str as String
dim ds as Dataset
Dim da as SqlDataAdapter
str="Select * from [Application] Where [Name] LIKE' " & Trim(Form1.txtsearch1.Text) & " ' ; "
 
        ds = New DataSet
        da = New SqlDataAdapter(str, con) '''Con is connection string pass your ''connection
        da.Fill(ds, "Application")
        DataGridView1.DataSource = ds
        DataGridView1.DataMember = "Application"

end sub
0

ooh, m sorry. Yes, i want all similar datas to be displayed as in starting with Letter....A. or if m looking for name tat starts with C all similar names starting with C....thanks for the reply

0
da = New OleDb.OleDbDataAdapter("Select * from Application Where Name LIKE'" & Trim(Form1.txtsearch1.Text).Substring(0,1) & "%'", "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=J:\Alumni\Alumni\Alumni\aadb.mdb")

try and replace this The code is
for A is

"Select * from Application Where Name LIKE'A%'"

For C is

"Select * from Application Where Name LIKE'C%'"
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.