当前位置:网站首页>C # connect to SQLite database to read content
C # connect to SQLite database to read content
2022-07-06 07:26:00 【weixin_ forty million nine hundred and thirty-eight thousand th】
Reference resources “System.ArgumentException” The first chance exception of type is System.Data.dll Occur in the
use C# visit SQLite introduction
SQLite And C# edition System.Data.SQLite Use
C# With the database SQLite: stay C# Project use SQLite
Realize in C# Through the statement , Query the data in the database
“System.ArgumentException” The first chance exception of type is System.Data.dll Occur in the
About c# in SqlDataReader Of GetString() Doubts about the method .
sqldataread in getstring() Use of methods
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SQLite;
namespace qq
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(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 name from sqlite_master where type='table' order by name;";
// load sql
SQLiteCommand cd = new SQLiteCommand(sql, dbConnection);
// perform
SQLiteDataReader dr = cd.ExecuteReader();
while (dr.Read())// Read
{
Console.Write(dr["name"]);
}
}
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 }); } */
}
}
}
边栏推荐
猜你喜欢
变量的命名规则十二条
Cookie技术&Session技术&ServletContext对象
TypeScript接口与泛型的使用
Do you really think binary search is easy
Force buckle day31
JDBC learning notes
Crawling exercise: Notice of crawling Henan Agricultural University
leetcode1020. Number of enclaves (medium)
leetcode704. Binary search (find an element, simple, different writing)
Significance and measures of encryption protection for intelligent terminal equipment
随机推荐
Relevant introduction of clip image
【线上问题处理】因代码造成mysql表死锁的问题,如何杀掉对应的进程
JDBC learning notes
mysql如何合并数据
Is software testing outsourcing going or not? Three years' real outsourcing experience tells you
You deserve this high-value open-source third-party Netease cloud music player
Go learning --- use reflection to judge whether the value is valid
Force buckle day31
合规、高效,加快药企数字化转型,全新打造药企文档资源中心
Mise en œuvre du langage leecode - C - 15. Somme des trois chiffres - - - - - idées à améliorer
Go learning -- implementing generics based on reflection and empty interfaces
#systemverilog# 可综合模型的结构总结
Multithreading and concurrent programming (2)
Win10 64 bit Mitsubishi PLC software appears oleaut32 DLL access denied
Introduction to the basics of network security
word怎么只删除英语保留汉语或删除汉语保留英文
Bugku CTF daily question: do you want seeds? Blackmailed
Three treasures of leeks and Chinese men's football team
Openjudge noi 2.1 1749: Digital Square
洛谷P4127 [AHOI2009]同类分布 题解