当前位置:网站首页>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 }); } */
}
}
}
边栏推荐
- 智能终端设备加密防护的意义和措施
- TypeScript接口与泛型的使用
- Google可能在春节后回归中国市场。
- supervisor 使用文档
- C语言 简单易懂的高精度加法
- 【mysql学习笔记30】锁(非教程)
- Chrome view page FPS
- [JDBC] quick start tutorial
- Oracle column to row -- a field is converted to multiple rows according to the specified separator
- Win10 64 bit Mitsubishi PLC software appears oleaut32 DLL access denied
猜你喜欢

leecode-C語言實現-15. 三數之和------思路待改進版

Do you really think binary search is easy

Fundamentals of C language 9: Functions

How are the open source Netease cloud music API projects implemented?

Summary of Digital IC design written examination questions (I)

MVVM of WPF

Week6 weekly report

Games101 Lesson 7 shading 1 Notes
![Ble of Jerry [chapter]](/img/d8/d080ccaa4ee530ed21d62755808724.png)
Ble of Jerry [chapter]

Ali's redis interview question is too difficult, isn't it? I was pressed on the ground and rubbed
随机推荐
智能终端设备加密防护的意义和措施
Openjudge noi 2.1 1749: Digital Square
软件测试界的三无简历,企业拿什么来招聘你,石沉大海的简历
CF1036C Classy Numbers 题解
Chrome view page FPS
杰理之普通透传测试---做数传搭配 APP 通信【篇】
Is the super browser a fingerprint browser? How to choose a good super browser?
Yield method of tread
Win10 64 bit Mitsubishi PLC software appears oleaut32 DLL access denied
超级浏览器是指纹浏览器吗?怎样选择一款好的超级浏览器?
合规、高效,加快药企数字化转型,全新打造药企文档资源中心
Scala language learning-08-abstract classes
How to configure GUI guide development environment
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
qt颜色与字符串、uint相互转换
(4) Web security | penetration testing | network security web site source code and related analysis
Lesson 12 study notes 2022.02.11
Multi attribute object detection on rare aircraft data sets: experimental process using yolov5
Select all the lines with a symbol in word and change them to titles
Full Score composition generator: living on code