Problem with Select statement im Ms Access DB

Nader

Well-known member
Joined
Oct 9, 2008
Messages
55
Programming Experience
Beginner
I'm using this Sql wiht Ms access DB. in vb.net2005

Dim sql As String = " SELECT A,B,C,D FROM Table1 where B Between '" & Me.TextBox1.Text & "' and '" & Me.TextBox2.Text & "'"

The Values of B column are 500-200-50-60-100
if I set to the TextBox1 =300 and TextBox2 = 55
the result is 500 -50

and as I know it must be like 200-100-60.
How to fix this problem?

 
Hi

Your problem is that you are trying to perform arthmetic operation on string/ text types, change the datatype of 'B' Column to Number rather than text. If you keep it text then current result are perfectly alright.
 
You should design and test the queries in access then copy them into your program.

With that said, you should be using parameterized queries for stuff like this too.
 
Back
Top