Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hey Guys,

 

I have beeen working on a program for my sisters company for some time now, but recently had a break from it. I am now back on track with it though finally! :)

 

I am stuck on how to search the database for records containing a word the user specifies. At the moment i have got the code

 

sql = "SELECT * FROM tblclient" & txtsurname.Text '' WILL NOT EARCH FOR SPECIFIED TEXT!!!!
       da = New OleDb.OleDbDataAdapter(sql, con)
       da.Fill(ds, "Eclypse Live")
       maxrows = ds.Tables("Eclypse Live").Rows.Count
       lbltotallresults.Text = maxrows & " clients found."
       inc = inc + 1
       lnkresult1.Text = ds.Tables("Eclypse Live").Rows(inc).Item(1) & " " & ds.Tables("Eclypse Live").Rows(inc).Item(2) & " / " & ds.Tables("Eclypse Live").Rows(inc).Item(0)
       inc = inc + 1
       lnkresult2.Text = ds.Tables("Eclypse Live").Rows(inc).Item(1) & " " & ds.Tables("Eclypse Live").Rows(inc).Item(2) & " / " & ds.Tables("Eclypse Live").Rows(inc).Item(0)
       inc = inc + 1
       lnkresult3.Text = ds.Tables("Eclypse Live").Rows(inc).Item(1) & " " & ds.Tables("Eclypse Live").Rows(inc).Item(2) & " / " & ds.Tables("Eclypse Live").Rows(inc).Item(0)
       inc = inc + 1
       lnkresult4.Text = ds.Tables("Eclypse Live").Rows(inc).Item(1) & " " & ds.Tables("Eclypse Live").Rows(inc).Item(2) & " / " & ds.Tables("Eclypse Live")

 

This displays the records in labels that i want but only ggooes through the database without filtering the results of a search.

 

I need to be able to search through the database for the surname of a person. This will be under item(1) and the search would be a string that the user enters...

 

Can anyone help?

 

The following is the code iss the SQL for getting all records from he database without filtering

 

SELECT * FROM tblclient

Posted

First, you'll want to look into Parameterizing your SQL (See also http://www.xtremedotnettalk.com/showthread.php?p=463520)

 

The second thing, is that you'll need to use the SQL LIKE keyword:

 

SELECT * FROM tblclient WHERE [FirstNameColumn] LIKE '%bob%';

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...