Ccan't filter integer column in DataView

I

Ivan Dimitrov

Hello,
I can't filter integer column in DataView
I have one TextBox that I retreive the value and one ComboBox where I
select column;
When column is string (LastName) everything working very well, but
when I select integer type (AccountNumber) generate an excpetion:

System.Data.EvaluateException: "Cannot perform 'Like' operation on
System.Int32 and System.String"


Thanks in advance

This is my source code:

private void SetUpFilter()
{
this.dvList.RowFilter = null;
if (this.txtFilterName.Text.Length != 0)
{
try
{
if (this.cmbFilterColumns.text.Length == 0)
{
MessageBox.Show("Select column");
return;
}


string filter = "["+ this.cmbFilterColumns.Text + "] LIKE '" +
txtFilterName.Text.ToString() + "%'";
this.dvList.RowFilter = filter;
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
ExceptionManager.Publish(ex);
}
}
}
 
E

Earl

LIKE is for character matching, you are trying to compare to an integer
value. If you are using SQL Server, check out LIKE in the BOL.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top