G
Guest
I'm using a DataView to filter a DataTable based on a long (Int64) value. I
sometimes get an EvaluateException (with the message shown in the subject
line above) on setting the RowFilter property of the DataView. I've tracked
it down to certain "magic" column values for a row already present and the
value I'm filtering for.
Here's a small sample app that demonstrates the problem. I'm using VS.NET
2003 and version 1.1 of the framework.
These are the only two magic values I've been able to isolate so far.
Can anyone shed some light on what causes this and how to avoid it?
Thanks,
Bill
using System;
using System.Data;
namespace DataViewBugDemo
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class BugDemo
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
// Create a table with one column
DataTable table = new DataTable("MyTable");
DataColumn column = table.Columns.Add("MyColumn", typeof(System.Int64));
// Add one row with magic value
DataRow row = table.NewRow();
row["MyColumn"] = -7343930372747648618;
table.Rows.Add(row);
// Create a data view
DataView view = new DataView(table);
// Filter for a second magic value
try
{
long filterValue = 6330035203988602880;
view.RowFilter = "MyColumn = " + filterValue.ToString();
Console.WriteLine("Curses, foiled again!");
}
catch (EvaluateException e)
{
Console.WriteLine("Gotcha! ");
Console.WriteLine("Exception: " + e.Message);
}
// Allow time to read the message
Console.ReadLine();
}
}
}
sometimes get an EvaluateException (with the message shown in the subject
line above) on setting the RowFilter property of the DataView. I've tracked
it down to certain "magic" column values for a row already present and the
value I'm filtering for.
Here's a small sample app that demonstrates the problem. I'm using VS.NET
2003 and version 1.1 of the framework.
These are the only two magic values I've been able to isolate so far.
Can anyone shed some light on what causes this and how to avoid it?
Thanks,
Bill
using System;
using System.Data;
namespace DataViewBugDemo
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class BugDemo
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
// Create a table with one column
DataTable table = new DataTable("MyTable");
DataColumn column = table.Columns.Add("MyColumn", typeof(System.Int64));
// Add one row with magic value
DataRow row = table.NewRow();
row["MyColumn"] = -7343930372747648618;
table.Rows.Add(row);
// Create a data view
DataView view = new DataView(table);
// Filter for a second magic value
try
{
long filterValue = 6330035203988602880;
view.RowFilter = "MyColumn = " + filterValue.ToString();
Console.WriteLine("Curses, foiled again!");
}
catch (EvaluateException e)
{
Console.WriteLine("Gotcha! ");
Console.WriteLine("Exception: " + e.Message);
}
// Allow time to read the message
Console.ReadLine();
}
}
}