数据库文件数据转存的问题,还有winform使用停表
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中弄出来。再此谢过了
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中弄出来。再此谢过了
...全文
相关推荐
WinForm读取Excel 并导入到数据库相应的表里
WinForm读取Excel 并导入到数据库相应的表里(有图有真相) 代码完整,如果是第一次 用WinForm 读取Excel数据的人 可以将代码直接Copy过去,不会出错也不需添加引用,并包含一个C#操作Excel类,功能比较全,有兴趣的人可以看看
C# winform treeView控件的使用绑定数据库
C# winform treeView控件的使用treeView1_BeforeExpand treeView绑定数据库
简单的winform读取SQL数据库数据
适合初学者,学习C# winform如何读取SQL数据库数据,请打开项目源码查看数据库名称和表名称,并建立数据库和表。也可修改为自己已有的数据库和表
c#_winform_打包(带数据库安装 )
C#winform程序打包发布,带数据库安装
winform连接数据库,可数据增删改查
winform连接数据库,包含数据库文件,可注册新用户,可对数据库数据增删改查


