当前位置:网站首页>C # create database connection object SQLite database
C # create database connection object SQLite database
2022-07-06 07:26:00 【weixin_ forty million nine hundred and thirty-eight thousand th】
Reference article source SQLite And C# edition System.Data.SQLite Use
class db {
private SQLiteConnection dbConnection;
//private SQLiteCommand cd;
//private SQLiteDataReader read;
public SQLiteConnection lian(string path)
{
// Create connection string
try
{
string databaseFileName = path;
string connectionString = "data source = " + databaseFileName;
// Linked database
dbConnection = new SQLiteConnection(connectionString);
dbConnection.Open();
}
catch (Exception e)
{
Console.Write(e);
}
return dbConnection;
}
}
namespace qq
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
db b= new db();
// Create connection string
string path="C:/QQ.db";
//string databaseFileName = "C:/QQ.db";
//string connectionString = "data source = " + databaseFileName;
// Linked database
//SQLiteConnection dbConnection = new SQLiteConnection(connectionString);
// Open database
//dbConnection.Open();
//sql sentence
string sql = "select name from sqlite_master where type='table' order by name;";
// load sql
SQLiteCommand cd = new SQLiteCommand(sql, b.lian(path));
// perform
SQLiteDataReader dr = cd.ExecuteReader();
while (dr.Read())// Read
{
//Console.Write(dr["name"]+"\n");
string str = dr["name"].ToString();
string pan = str.Substring(0, 6);
//Console.Write(pan+"\n");
if (pan == "tb_Tro"||pan=="tb_c2c") {
Console.Write(pan + "\n");
}
}
}
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
// Create connection string
string databaseFileName = "C:/QQ.db";
string connectionString = "data source = " + databaseFileName;
// Linked database
SQLiteConnection dbConnection = new SQLiteConnection(connectionString);
// Open database
dbConnection.Open();
//sql sentence
string sql = "select * from tb_c2cMsg_1030331506";
// load sql
SQLiteCommand cd = new SQLiteCommand(sql, dbConnection);
// perform
SQLiteDataReader dr = cd.ExecuteReader();
while (dr.Read())// Read
{
DateTime d = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));// Turn the timestamp to mm / DD / yyyy
long t = long.Parse(dr["time"] + "0000000");
TimeSpan to = new TimeSpan(t);
Console.Write(d.Add(to) + "\n");
var time6 = d.Add(to);
ListViewItem lt = new ListViewItem();
// Convert database data into ListView A row of data of type
lt.Text = dr["uin"].ToString();
lt.SubItems.Add(time6.ToString());
//lt.SubItems.Add(dr["pwd"].ToString());
// take lt Data added to listView1 Control
listView1.Items.Add(lt);
int panduan = dr.GetInt32(4);
//Console.Write(panduan);
if (panduan == 1)
{
Console.Write(" other party ");
}
else
{
Console.Write(" I ");
}
//var tempStr =dr["time"];
var p = dr["content"];
// Get plain text with getstring Get serial number with getordinal For getting numbers getint32
Console.Write(p + "\n");
}
/* cnn.Open(); string sql = "select * from tb_c2cMsg_1030331506"; SQLiteCommand cmd = cnn.CreateCommand(); cmd.CommandText = sql; SQLiteDataReader reader = cmd.ExecuteReader(); //List<ImportInfo> infoList = new List<ImportInfo>(); while (reader.Read()) { // ImportInfo info = new ImportInfo(); var tempStr = reader.GetString(4); Console.Write(tempStr); //dynamic jsonInfos = JsonConvert.DeserializeObject(tempStr); //var episode_title = jsonInfos.episode_title.ToString(); //var audio_file_name = jsonInfos.audio_file_name.ToString(); //var lrc_file_name = jsonInfos.lrc_file_name.ToString(); //infoList.Add(new ImportInfo() { data1 = data1, data2 = data2 }); } */
}
}
}
边栏推荐
- Path analysis model
- Bugku CTF daily question: do you want seeds? Blackmailed
- NiO programming introduction
- Methods for JS object to obtain attributes (. And [] methods)
- Oracle database 11gr2 uses TDE transparent data encryption to report an error ora28353. If you run to close the wallet, you will report an error ora28365. If you run to open the wallet, you will repor
- JMeter performance test steps practical tutorial
- Typescript variable scope
- Related operations of Excel
- Select all the lines with a symbol in word and change them to titles
- The way to learn go (II) basic types, variables and constants
猜你喜欢
Force buckle day31
Three no resumes in the software testing industry. What does the enterprise use to recruit you? Shichendahai's resume
When the Jericho development board is powered on, you can open the NRF app with your mobile phone [article]
ORACLE列转行--某字段按指定分隔符转多行
Leetcode 78: subset
How to delete all the words before or after a symbol in word
MVVM of WPF
leetcode704. Binary search (find an element, simple, different writing)
杰理之BLE【篇】
杰理之BLE【篇】
随机推荐
[MySQL learning notes 30] lock (non tutorial)
TypeScript 接口属性
Three no resumes in the software testing industry. What does the enterprise use to recruit you? Shichendahai's resume
leecode-C語言實現-15. 三數之和------思路待改進版
Oracle database 11gr2 uses TDE transparent data encryption to report an error ora28353. If you run to close the wallet, you will report an error ora28365. If you run to open the wallet, you will repor
Set picture annotation in markdown
Leetcode35. search the insertion position (simple, find the insertion position, different writing methods)
TypeScript 可索引类型
网络安全基础介绍
The way to learn go (I) the basic introduction of go to the first HelloWorld
Games101 Lesson 7 shading 1 Notes
JDBC learning notes
mysql如何合并数据
Ble of Jerry [chapter]
word怎么只删除英语保留汉语或删除汉语保留英文
Significance and measures of encryption protection for intelligent terminal equipment
1091: two or three things in childhood (multi instance test)
Go learning --- use reflection to judge whether the value is valid
SSM学习
Select all the lines with a symbol in word and change them to titles