你如果你OLEDB的话,文件不大时可以用byte[]读出所有记录,如果记录集很大,你可以使用
DataReader reader = Command.ExecuteReader( CommandBehavior.SequentialAccess ) ;
在用reader.GetBytes每一次取出一定量的字节,取后存到文件中,然后再取直到取完为止,VB.NET有这个的帮助
DataReader reader = Command.ExecuteReader( CommandBehavior.SequentialAccess ) ;
在用reader.GetBytes每一次取出一定量的字节,取后存到文件中,然后再取直到取完为止,VB.NET有这个的帮助
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;using System.Data.OleDb ;
namespace nsgl.main
{
/// <summary>
/// doc 的摘要说明。
/// </summary>
public class doc : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{ try
{
byte[] buf = new byte[1000] ;
string sql = string.Format( "select YOURBLOB FROM " ) ;
OleDbCommand cmd = con.createCommand() ;
cmd.CommandText = sql ; FileStream fs = new FileStream( "c:\11.txt" ) ;
BinaryWriter bw = new BinaryWriter( fs ) ; IDataReader dataReader = cmd.ExecuteReader( CommandBehavior.SequentialAccess ) ;
if( dataReader.Read() )
{
long retval ;
long startIndex = 0 ;
byte[] buf = new byte[1000]; do
{
retval = dataReader.GetBytes( 0 , startIndex , buf , 0 , 1000 ) ;
startIndex = retval + startIndex ;
bw.Write( buf ) ;
bw.flush( ) ;
} while( retval == 1000 ) ;
}
}
catch( Exception ex )
{
} bw.close() ;
fs.close() ;
con.close() ;
}
}