C# 注册并使用sqlite 自定义函数
2014-03-08 14:43
337 查看
C# 注册并使用sqlite 自定义函数
http://blog.csdn.net/keenweiwei/article/details/8899719 http://stackoverflow.com/questions/1943704/sqlitefunction-simple-not-working
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] ) ;
}
}
http://blog.csdn.net/keenweiwei/article/details/8899719 http://stackoverflow.com/questions/1943704/sqlitefunction-simple-not-working
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] ) ;
}
}
相关文章推荐
- 使用C#自动注册自定义文件类型
- C# 注册并使用sqlite 自定义函数
- 使用C#自动注册自定义文件类型
- 使用C#自动注册自定义文件类型
- 在C#中创建SQLite自定义函数
- 使用sqlite3(数据库知识)的接口函数完成一个用户注册功能模块设计 要封装成函数,在独立的main中调用测试
- 写 smarty 插件 前奏 动态 注册 自定义 php 函数 模板中使用
- 使用C#自动注册自定义文件类型
- C#使用yield关键字让自定义集合实现foreach遍历的方法
- CodeProject - 在C#使用SHGetFileInfo获取(管理)文件或者文件夹图标(C#封装Win32函数的一个例子)
- 使用Signature Tool自动生成P/Invoke调用Windows API的C#函数声明
- 如何在基于MFC的环境中使用自定义消息函数?
- 在spring中使用自定义注解注册监听器的方法
- C#中增加SQLite事务操作支持与使用方法
- 8.1.3 在 C# 中使用函数集合
- thinPHP使用自定义函数
- C#中使用自定义的纸张大小
- .net c# winform带验证功能的TextBox,支持正则和自定义验证函数
- C# 使用Newtonsoft.Json序列化自定义类型
- C#软件开发实例.私人订制自己的屏幕截图工具(九)使用自定义光标,QQ截图时的光标