【发布时间】:2010-12-28 23:01:38
【问题描述】:
我试图从我的 C# 和 ADO.NET 代码中使用 SQLiteFunction。谁能说出我为什么会遇到这个问题?
System.Data.SQLite.dll 中出现“System.Data.SQLite.SQLiteException”类型的未处理异常 附加信息:“DEMOIT”附近的 SQLite 错误:语法错误
我正在使用带有 SQLite ADO.NET 1.0.65 的 .NET 3.5 x86 - 帮助!
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] ) ;
}
}
谢谢!
【问题讨论】:
-
您的 SQL 中存在语法错误。靠近
DEMOIT。
标签: c# sqlite ado.net function