问题描述
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Diagnostics;usingSystem.Data.Common;usingSystem.Data.SQLite;usingSystem.IO;namespaceWindowsFormsApplication3{publicpartialclassForm1:Form{publicForm1(){InitializeComponent();}privatevoidForm1_Load(objectsender,EventArgse){System.Data.SQLite.SQLiteConnection.CreateFile("datasource");System.Data.SQLite.SQLiteConnectionconn=newSystem.Data.SQLite.SQLiteConnection();stringdatasource="D:/Data.db";System.Data.SQLite.SQLiteConnectionStringBuilderconnstr=newSystem.Data.SQLite.SQLiteConnectionStringBuilder();connstr.DataSource=datasource;conn.ConnectionString=connstr.ToString();conn.Open();System.Data.SQLite.SQLiteCommandcmd=newSystem.Data.SQLite.SQLiteCommand();cmd.Connection=conn;Stopwatchwatch=newStopwatch();watch.Start();stringsql="SELECT*FROMtestWHERESLIKE'%100'";cmd.CommandText=sql;cmd.ExecuteNonQuery();System.Data.SQLite.SQLiteDataReaderreader=cmd.ExecuteReader();watch.Stop();saveFileDialog1.Filter="二进制文件(*.dat)|*.dat";if(saveFileDialog1.ShowDialog()==DialogResult.OK){FileStreammyStream=newFileStream(saveFileDialog1.FileName,FileMode.OpenOrCreate,FileAccess.ReadWrite);BinaryWritermyWriter=newBinaryWriter(myStream);myWriter.Write(reader.Read());myWriter.Close();myStream.Close();}}}}是不是这句错了?select的结果无法存入二进制文件中。还有谁能把停表的显示在winForm中弄出来。再此谢过了
解决方案
解决方案二:
myWriter.Write()这里没有写对象的重载吧,你看看那个类的用法http://msdn.microsoft.com/zh-cn/library/system.io.binarywriter.write(v=vs.80).aspx
解决方案三:
reader.Read()返回的不是内容,你看看帮助,用索引访问内容reader[0],reader[1]