By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,569 Members | 1,630 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,569 IT Pros & Developers. It's quick & easy.

ado troubles with vb.net 2003

P: n/a
I am having trouble querying an Access database with ADO .NET in VB .NET. I
can get results returned using primary keys, but when using something like
LastName, nothing happens. I am not sure why this is. Here is the query
that works, and the one that doesn't:

Works:
cmd = New OleDbCommand("select * from employee where EmployeeID= " &
txtEmployeeID.Text, cn)

Does Not Work:
cmd = New OleDbCommand("select * from employee where EmpLastName like " &
txtLast.Text, cn)

Any help would be greatly appreciated,

Rubber Steve


Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Do this :

cmd = New OleDbCommand("select * from employee where EmpLastName like '%" +
txtLast.Text + "%'", cn)

And try...^^ Don't forget the single quote !

Pierrick

"Rubber Steve" <ru*********@steverino.com.nospam> a écrit dans le message de
news:DN*********************@twister.tampabay.rr.c om...
I am having trouble querying an Access database with ADO .NET in VB .NET. I can get results returned using primary keys, but when using something like
LastName, nothing happens. I am not sure why this is. Here is the query
that works, and the one that doesn't:

Works:
cmd = New OleDbCommand("select * from employee where EmployeeID= " &
txtEmployeeID.Text, cn)

Does Not Work:
cmd = New OleDbCommand("select * from employee where EmpLastName like " &
txtLast.Text, cn)

Any help would be greatly appreciated,

Rubber Steve

Nov 20 '05 #2

P: n/a
"pierrick-allusse" <pi**************@wanadoo.fr> wrote in message
news:cd**********@news-reader5.wanadoo.fr...
Do this :

cmd = New OleDbCommand("select * from employee where EmpLastName like '%" + txtLast.Text + "%'", cn)

And try...^^ Don't forget the single quote !


Thank you. You were most helpful! :)

Rubber Steve
Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.