Reputation: 13
I have an integer in a textbox(Integer retrieved from another form using TOstring) I want to use in an sql select statement.
For example, select * from table where column = textbox
. The problem is, npgsql gives an error saying I'm trying to pass string into integer column. I try to cast(::int) but still got errors.
Any ideas!
Upvotes: 0
Views: 389
Reputation: 1
You can do it like this.
string text = textbox.Text;
int id;
bool isConvertibleToInteger = int.TryParse(text, out id);
Please avoid select *
, instead provide the column names
Upvotes: 1
Reputation: 13
I solved this issue. I called the SQL on tab click event and all worked fine. Datagridview properly filtered out the rows using textbox integer input. –
Upvotes: 0