当前位置:网站首页>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 }); } */
}
}
}
边栏推荐
- [MySQL learning notes 30] lock (non tutorial)
- Lesson 12 study notes 2022.02.11
- Set picture annotation in markdown
- 杰理之BLE【篇】
- 1091: two or three things in childhood (multi instance test)
- LeetCode Algorithm 2181. Merge nodes between zero
- Typescript function definition
- Word setting directory
- word中把带有某个符号的行全部选中,更改为标题
- How can word delete English only and keep Chinese or delete Chinese and keep English
猜你喜欢
leetcode841. Keys and rooms (medium)
Ali's redis interview question is too difficult, isn't it? I was pressed on the ground and rubbed
杰理之开发板上电开机,就可以手机打开 NRF 的 APP【篇】
The best way to learn SEO: search engine
Leetcode35. search the insertion position (simple, find the insertion position, different writing methods)
Leecode-c language implementation -15 Sum of three ----- ideas to be improved
leetcode704. Binary search (find an element, simple, different writing)
QT color is converted to string and uint
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
杰理之AD 系列 MIDI 功能说明【篇】
随机推荐
杰理之开发板上电开机,就可以手机打开 NRF 的 APP【篇】
Scala language learning-08-abstract classes
TypeScript void 基础类型
Google可能在春节后回归中国市场。
word中把帶有某個符號的行全部選中,更改為標題
杰理之BLE【篇】
ORACLE列转行--某字段按指定分隔符转多行
[CF Gym101196-I] Waif Until Dark 网络最大流
Seriously recommend several machine learning official account
Get/post/put/patch/delete meaning
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
Ble of Jerry [chapter]
Leecode-c language implementation -15 Sum of three ----- ideas to be improved
[MySQL learning notes 30] lock (non tutorial)
On the world of NDK (2)
[MySQL learning notes 32] mvcc
Is software testing outsourcing going or not? Three years' real outsourcing experience tells you
TypeScript 接口属性
Méthode d'obtention des propriétés de l'objet JS (.Et [] méthodes)
js对象获取属性的方法(.和[]方式)