码迷,mamicode.com
首页 > 数据库 > 详细

SQLite初试...

时间:2016-08-12 11:32:26      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:

            string dataPath = "../../UserData.dbx"; //System.IO.Directory.GetCurrentDirectory() + "\\UserData.dbx";
            SQLiteConnection.CreateFile(dataPath);
            SQLiteConnection conn = new SQLiteConnection("Data Source=" + dataPath);
            conn.Open();


            SQLiteCommand cmd = new SQLiteCommand();
            cmd.CommandText = "create table Users (UserID int primary key,UserName varchar(100) not null,UserPassword varchar(100) not null)";
            cmd.Connection = conn;
            cmd.ExecuteNonQuery();

            for (int i = 0; i < 10; i++)
            {
                cmd.CommandText = "insert into Users (UserID,UserName,UserPassword) values (" + i + ",‘TestUser_" + i + "测试‘,‘" + DateTime.Now.ToString().Replace(" ", "-").Replace(":", "-") + "‘)";
                cmd.ExecuteNonQuery();
            }

 

SQLite初试...

标签:

原文地址:http://www.cnblogs.com/love-zf/p/5764001.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!