110,537
社区成员
发帖
与我相关
我的任务
分享
SQLiteClient db = new SQLiteClient(@"C:\Documents and Settings\wubucool\桌面\test.db");
会有这样的提示信息:未处理 System.IO.FileLoadExceptionusing 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();
}
}
}
private void button1_Click(object sender, EventArgs e)
{
sqliteConn.SqliteHelper sqltest = new SqliteHelper(Application.ExecutablePath);
sqltest.connTest();
}