Hi there,
This behaviour could be caused because you're asking the database to return an
integer
value (the return value min/max from the database) based on a
string
(text) input. You could try to parse the textbox value to an integer like :
int i = Convert.ToInt32(textbox1.Text.Trim());
and then feed that value to the database using an sql query (mind the quotes) :
da=new oledbdataadapter("Select modelname from table where type='gate' and min <= i and max >= i",con);
also I notice a typo in your original query, not sure if that's a copy/paste issue but it will certainly return an inproper value if you use it like that. You forgot a couple of quotes :
da = new oledbdataadapter("SELECT modelname FROM table WHERE type='gate' AND min <= '" + textbox1.text + "' AND max >= '" + textbox1.text + "'",con);
The inaccurate use of quotes is responsible for 90% of invalid results of database queries or database query failures. Hope this helps