您的位置:首页 > 数据库

sqlite基本

2015-08-13 22:07 453 查看

1、工具:SQLiteStudio

2、c#中sqlite操作

示例:

class Program
{
static void Main(string[] args)
{
string connStr = @"Data Source=DB/example.db;version=3;";
string sql = "insert into TestDB(sName,sSex,sBirthdate,sInputTime) values(@sName,@sSex,@sBirthdate,@sInputTime);";
using (SQLiteConnection conn=new SQLiteConnection(connStr))
{
using (SQLiteCommand cmd=new SQLiteCommand(sql,conn))
{
SQLiteParameter[] ps = {
new SQLiteParameter("@sName","testname"),
new SQLiteParameter("@sSex","m"),
new SQLiteParameter("@sBirthdate","2000-1-1"),
new SQLiteParameter("@sInputTime",DateTime.Now),

};
cmd.Parameters.AddRange(ps);
conn.Open();
int count = cmd.ExecuteNonQuery();
Console.WriteLine("{0}行受到影响",count);
}
}
Console.ReadKey();
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: