Wednesday, March 21, 2012

Retrieving multiple rows from data base.

OK here's my question. I want to retrieve from my database employee table all those employees with the name eg. Smith and display them in a list. Can anyone give me any pointers please. I'm using VB 2005 Express Edition. So far this is what I have but it only seems to return 1 row when I know there are more than one entries with the name I am inputting

PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim searchString AsString

searchString = Me.SearchStringBox.Text

Try

Dim filter AsString

filter = "LastName LIKE '" & searchString & "'"

Dim search() As System.Data.DataRow

search = myCDDataSEt.ClientData.Select(filter)

If search.Length > 0 Then

'no code as yet

Else

MessageBox.Show("The client " & searchString & "is not in the database")

EndIf

Catch ex As Exception

MessageBox.Show(ex.Message)

EndTry

EndSub

All of the SQL that I see in this is LastName LIKE... If you want help with the SQL, you need to print it out and let us look at it. Otherwise, we need to move the thread over to a VB programming group to look at.|||Sorry thought I was in another forum. !

No comments:

Post a Comment