首页新闻找找看学习计划

Sqlite memory 数据库

0
悬赏园豆:20 [已关闭问题] 关闭于 2010-08-26 10:32

我在内存中创建数据库,在open() 的时候就报错,看了很多文档都没有找到答案,希望博客园有大牛帮忙解决下,先谢了

IDbConnection dbcon;
dbcon
= (IDbConnection)new SQLiteConnection("URI=file::memory:,version=3");
dbcon.Open();
IDbCommand dbcmd
= dbcon.CreateCommand();
// requires a table to be created named employee
// with columns firstname and lastname
// such as,
// CREATE TABLE employee (
// firstname varchar(32),
// lastname varchar(32));
string sql =
"SELECT firstname, lastname " +
"FROM employee";
dbcmd.CommandText
= sql;
IDataReader reader
= dbcmd.ExecuteReader();
while (reader.Read())
{
string FirstName = reader.GetString(0);
string LastName = reader.GetString(1);
Console.WriteLine(
"Name: " +
FirstName
+ " " + LastName);
}
// clean up
reader.Close();
reader
= null;
dbcmd.Dispose();
dbcmd
= null;
dbcon.Close();
dbcon
= null;

 

问题补充: 错误信息 Invalid ConnectionString format for parameter "URI"
jackyong的主页 jackyong | 初学一级 | 园豆:149
提问于:2010-08-25 15:36
< >
分享
所有回答(3)
0

你报啥错,你总得把错误贴出来吧。

Launcher | 园豆:45040 (高人七级) | 2010-08-25 16:45
0

URI=file::memory:,version=3

格式不对......你再检查检查吧......

liangxiaxu | 园豆:190 (初学一级) | 2012-10-31 11:23
0

跟你的错误一样,请问i后来解决了吗?

码农日志 | 园豆:202 (菜鸟二级) | 2012-11-15 16:12
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册