المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Filtering Problem in Sql Syntax using C#.net



C# Programming
08-10-2011, 02:30 PM
Hi All !
I use this Syntax for Filtering LastName field :
string strFilter = "LastName like '" + txtFamily.Text + "%'";dvShowTable = new DataView(dataconn.dSet.Tables["PersonTable"], "", "", DataViewRowState.OriginalRows);dvShowTable.RowFilter = strFilter;dgShowTable.DataSource = dvShowTable;if (dvShowTable.Count == 0){ MessageBox.Show("No find any Record !"); txtFamily.Text = ""; return;}
It's works , but another filtering is about Account Field and I use this Syntax :
string strFilterAccount = "AccountNo like '" + Convert.ToDouble(txtAccount.Text)+"%'";I have this Error:
Cannot perform 'Like' operation on System.Double and System.String

And If i use this syntax :

string strFilterAccount = "AccountNo="+ Convert.ToDouble(txtAccount.Text);mmediately i put any Number , you get the message in the "If" conditional .

what is suitable instead of Like for number Field !
thanks