C# 连接SQLite的问题

沉睡的悟空 2010-11-27 04:39:00
各位帮帮忙哈!现在我有个小型的数据库放在本地,所以想用SQLite去处理。但不知道怎么连接和使用。我已经下过SQLiteProxy.dll和SQLiteClient.dll了。但建立SQLiteClient对象时
                SQLiteClient db = new SQLiteClient(@"C:\Documents and Settings\wubucool\桌面\test.db");
会有这样的提示信息:未处理 System.IO.FileLoadException
Message=混合模式程序集是针对“v1.1.4322”版的运行时生成的,在没有配置其他信息的情况下,无法在 4.0 运行时中加载该程序集。
拜托各位帮帮忙哈 急!!!
...全文
239 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
沉睡的悟空 2010-12-01
  • 打赏
  • 举报
回复
万分感谢 !!! O(∩_∩)O哈哈~
wuyq11 2010-11-28
  • 打赏
  • 举报
回复
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>
Data Source=filename;Version=3;Password=myPassword;
http://www.codeproject.com/KB/cs/SQLiteCSharp.aspx?display=PrintAll&fid=941676&df=90&mpp=25&noise=3&sort=Position&view=Quick
沉睡的悟空 2010-11-27
  • 打赏
  • 举报
回复
是不是我用的vs2010有问题呀??
提示信息老是显示:{"混合模式程序集是针对“v2.0.50727”版的运行时生成的,在没有配置其他信息的情况下,无法在 4.0 运行时中加载该程序集。":null}
就是它在4.0的框架下没办法用是不是。
还有就是这个SQLite从来没用过。下载后也不知道怎么个用法,说起来真是汗死。知道用法和SqlServer和MySQL都差不多,但就是不知道怎么个入口(客户端什么的都没有。就一个驱动文件,怎么用哇??)
lihaoran8577 2010-11-27
  • 打赏
  • 举报
回复
SqliteHelper.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SQLite;
namespace sqliteConn
{
public class SqliteHelper
{
string apppath="";

public SqliteHelper(string applicationPath)
{
apppath = applicationPath.Substring(0,applicationPath.LastIndexOf("\\"));
}



public void connTest()
{
string connstr = string.Format("Data Source={0}", apppath+"\\hy.db");
SQLiteConnection cn = new SQLiteConnection(connstr);
cn.Open();
SQLiteCommand cmd = cn.CreateCommand();
cmd.CommandText = "select * from mysqltetable";
SQLiteDataReader reader = cmd.ExecuteReader() ;
while (reader.Read())
{
string msg = string.Format("id:'{0}' + name:'{1}'",reader.GetInt16(0), reader.GetString(1));
System.Windows.Forms.MessageBox.Show(msg);
}
reader.Close();
cmd.Dispose();
cn.Close();
cn.Dispose();
}
}
}

From1
private void button1_Click(object sender, EventArgs e)
{
sqliteConn.SqliteHelper sqltest = new SqliteHelper(Application.ExecutablePath);
sqltest.connTest();
}

110,537

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧