Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

retrieve data from access database

Status
Not open for further replies.

sicohne

Technical User
Jun 30, 2003
51
GB
I have a table in an access database containing all long integers. Trying to retrieve the data brings up the error "data type mismatch in expression". The retrieval code is as follows
Code:
Dim da5 As New OleDbDataAdapter("SELECT * FROM Charges WHERE lowamount <'" & CLng(AmountBox1.Text) & "'", cn)
Am I missing something obvious?
 
Code:
Dim da5 As New OleDbDataAdapter("SELECT * FROM Charges WHERE lowamount <'" & AmountBox1.Text & "'", cn)

And even better than this...and far safer, use SQL Parameters!

Sweep
...if it works dont f*** with it
curse.gif
 
you don't need to add the single quotes for numeric values

Code:
Dim da5 As New OleDbDataAdapter("SELECT * FROM Charges WHERE lowamount <" & AmountBox1.Text , cn)

and like he said


And even better than this...and far safer, use SQL Parameters!
And even better than this...and far safer, use SQL Parameters!
And even better than this...and far safer, use SQL Parameters!
And even better than this...and far safer, use SQL Parameters!
And even better than this...and far safer, use SQL Parameters!
And even better than this...and far safer, use SQL Parameters!
And even better than this...and far safer, use SQL Parameters!


Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
Whoops...I forgot to take the single quotes off.

Sweep
...if it works dont f*** with it
curse.gif
 
Thanks for that.

I'm fairly new to this and have no idea what you mean by SQL parameters (time for a google search I guess).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top