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)

            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

        Catch myException As Exception

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

Any Ideas?



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%'));"


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.