Dataset Filter Interger
-
I have a dataset filled from SqlDataAdapter, and I would like to filter the dataset. The column I would like to filter is customerID, which have int data type. I thought I can use :
int cust_search = Int32.Parse(txt_custsearch.Text.ToString()); ds_customer.Tables["Customer_table"].DefaultView.RowFilter = "CustomerID = 'cust_search'";
I know here cust_search have to be in string to have the code to work properly. What should I use to filter interger value in my dataset? Thank you so much in advance. -
I have a dataset filled from SqlDataAdapter, and I would like to filter the dataset. The column I would like to filter is customerID, which have int data type. I thought I can use :
int cust_search = Int32.Parse(txt_custsearch.Text.ToString()); ds_customer.Tables["Customer_table"].DefaultView.RowFilter = "CustomerID = 'cust_search'";
I know here cust_search have to be in string to have the code to work properly. What should I use to filter interger value in my dataset? Thank you so much in advance.Well, for one, don't use .ToString() on a Text property. It's already a String!
int cust_search = Int32.Parse(txt_custsearch.Text);
ds_customer.Tables["Customer_table"].DefaultView.RowFilter = "CustomerID = " + cust_search.ToString();RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
Well, for one, don't use .ToString() on a Text property. It's already a String!
int cust_search = Int32.Parse(txt_custsearch.Text);
ds_customer.Tables["Customer_table"].DefaultView.RowFilter = "CustomerID = " + cust_search.ToString();RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
It worked. Thanks a lot :)
-
Well, for one, don't use .ToString() on a Text property. It's already a String!
int cust_search = Int32.Parse(txt_custsearch.Text);
ds_customer.Tables["Customer_table"].DefaultView.RowFilter = "CustomerID = " + cust_search.ToString();RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
Is it possible to filter with wildcard? I tried:
cust_name_search = txt_custname_search.Text + "%"; dataview_cust_search.RowFilter = "cust_name LIKE " + cust_name_search;
It comes with error saying that "Missing Operand after Mod operation". I know that '%' is the wildcard for Sql Command, but what wildcard do I use for dataview rowfilter, and how do I do it? Thank you very much in advance. -
Is it possible to filter with wildcard? I tried:
cust_name_search = txt_custname_search.Text + "%"; dataview_cust_search.RowFilter = "cust_name LIKE " + cust_name_search;
It comes with error saying that "Missing Operand after Mod operation". I know that '%' is the wildcard for Sql Command, but what wildcard do I use for dataview rowfilter, and how do I do it? Thank you very much in advance.Strings in SQL must be enclosed in single quotes. cust_name_search = "'" + txt_custname_search.Text + "%'"; dataview_cust_search.RowFilter = "cust_name LIKE " + cust_name_search; Also, Wildcard characters, * and %, are supported and are used with the LIKE operator. Wildcards are allowed only at the beginning and/or end of a filter string. Regards, Orina http://orina.org
-
Strings in SQL must be enclosed in single quotes. cust_name_search = "'" + txt_custname_search.Text + "%'"; dataview_cust_search.RowFilter = "cust_name LIKE " + cust_name_search; Also, Wildcard characters, * and %, are supported and are used with the LIKE operator. Wildcards are allowed only at the beginning and/or end of a filter string. Regards, Orina http://orina.org
Thank you so much, it works perfectly :)
-
Strings in SQL must be enclosed in single quotes. cust_name_search = "'" + txt_custname_search.Text + "%'"; dataview_cust_search.RowFilter = "cust_name LIKE " + cust_name_search; Also, Wildcard characters, * and %, are supported and are used with the LIKE operator. Wildcards are allowed only at the beginning and/or end of a filter string. Regards, Orina http://orina.org
Can I actually use LIKE in row filter for interger? For example I have these following record I want to filter: 1100 1101 1200 1201 1202 1203 1300 1301 When I typed '12' in the textbox, only record with 12 as the beginning appear (1200, 1201, 1202, 1203). I tried:
string CustomerID = "'" + txt_customerid.Text + "%'"; dataview_cust_search.RowFilter = "CustomerID LIKE " + CustomerID;
But error showed up saying that I cannot use LIKE on string with integer. Is there anyway I can do this? Also, is it possible to filter date? Please help. Thank you very much in advance. -
Strings in SQL must be enclosed in single quotes. cust_name_search = "'" + txt_custname_search.Text + "%'"; dataview_cust_search.RowFilter = "cust_name LIKE " + cust_name_search; Also, Wildcard characters, * and %, are supported and are used with the LIKE operator. Wildcards are allowed only at the beginning and/or end of a filter string. Regards, Orina http://orina.org