I an attempting to use a SQLiteFunction from my C# and ADO.NET code. Can anyone say why I get this problem?
An unhandled exception of type 'System.Data.SQLite.SQLiteException' occurred in System.Data.SQLite.dll Additional information: SQLite error near "DEMOIT": syntax error
I am using .NET 3.5 x86 with SQLite ADO.NET 1.0.65 - Help!
public class Program
{
static void Main( string[ args )
{
test();
}
public static void test()
{
SQLiteConnection sqlConn = new SQLiteConnection( "Data Source=TestFoods.db;" );
sqlConn.Open();
SQLiteCommand sqlCmd = new SQLiteCommand( "PRAGMA integrity_check" , sqlConn);
sqlCmd.ExecuteNonQuery();
SQLiteFunction.RegisterFunction( typeof(DEMOIT) );
sqlCmd = new SQLiteCommand( "SELECT * FROM Foods Where Foods.Name DEMOIT '$butter' " , sqlConn );
sqlCmd.CommandType = CommandType.Text;
SQLiteDataAdapter liteAdapter = new SQLiteDataAdapter( sqlCmd );
DataSet dataSet = new DataSet();
liteAdapter.Fill( dataSet , "Foods" );
}
}
[SQLiteFunction( Name = "DEMOIT" , Arguments = 1 , FuncType = FunctionType.Scalar )]
public class DEMOIT : SQLiteFunction
{
public override object Invoke( object[] args )
{
return Convert.ToString( args[0] ) ;
}
}
Thanks!