0

Hey all,


I am having a little trouble with my sql and VB.net I think

There it is I want to select records from a customer table which is like what the user types in (So they don't have to be exact matches. The statment runs but I don't think it is running correctly I stops after the first record which is the exact macth the the name I type in.
Here Is the code I am using. I just put James in instead of the text box value.

LastCus = "Select * from tblCustomer where  ((Cus_Name Like 'James'));"
            connetionString = "Provider = Microsoft.ACE.OLEDB.12.0;Data Source = KellihersLawnmowers.accdb"
            cnn = New OleDbConnection(connetionString)
            cnn.Open()

            cmd = New OleDbCommand(LastCus, cnn)
            reader = cmd.ExecuteReader()


            While reader.Read()
                CustomerID = reader.Item(0)
                FoundName = reader.Item(1)
                foundNumber = reader.Item(2)
            End While
            reader.Close()
            cmd.Dispose()
            cnn.Close()

        Catch myException As Exception
      
        Finally
            reader.Close()
            cmd.Dispose()

The Codes runs find but only ever returns the exacty match.

Any Ideas?


Thanks

James

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by JAM1011
0

I think you need to wrap your search string with %. I regularly reference this page for SQL information and it says your statement should be as follows:
"LastCus = "Select * from tblCustomer where ((Cus_Name Like '%James%'));"

HTH

0

Hey Stevoni

Thanks for the fast relpy.

That was the solved my problem.

Thanks very much

This question has already been answered. 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.