数据库文件数据转存的问题,还有winform使用停表

bs897945043 bs897945043 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Data.Common;
using System.Data.SQLite;
using System.IO;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
System.Data.SQLite.SQLiteConnection.CreateFile("datasource");

System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection();

string datasource = "D:/Data.db";

System.Data.SQLite.SQLiteConnectionStringBuilder connstr = new System.Data.SQLite.SQLiteConnectionStringBuilder();

connstr.DataSource = datasource;

conn.ConnectionString = connstr.ToString();

conn.Open();

System.Data.SQLite.SQLiteCommand cmd = new System.Data.SQLite.SQLiteCommand();

cmd.Connection = conn;

Stopwatch watch = new Stopwatch();

watch.Start();

string sql = "SELECT * FROM test WHERE S LIKE '%100'";

cmd.CommandText = sql;

cmd.ExecuteNonQuery();

System.Data.SQLite.SQLiteDataReader reader = cmd.ExecuteReader();

watch.Stop();

saveFileDialog1.Filter = "二进制文件(*.dat)|*.dat";

if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{

FileStream myStream = new FileStream(saveFileDialog1.FileName, FileMode.OpenOrCreate, FileAccess.ReadWrite);

BinaryWriter myWriter = new BinaryWriter(myStream);

myWriter.Write(reader.Read());
myWriter.Close();

myStream.Close();

}

}
}
}
是不是这句错了?select的结果无法存入二进制文件中。还有谁能把停表的显示在winForm中弄出来。再此谢过了
...全文
评论 2
收藏 已收藏
分享
返回顶部
bs897945043
C# 111,130 成员 642,539 内容