Dim conn As OleDb.OleDbConnection = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\db.mdb") Dim cmd As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter("select * from 1", conn) Dim dst As DataSet = New DataSet cmd.Fill(dst) Response.Charset = "UTF-8" Response.AppendHeader("Content-Disposition", "attachment;filename=aa.htm") Response.ContentEncoding = System.Text.Encoding.Default Dim tw As System.IO.StringWriter = New System.IO.StringWriter Dim hw As Web.UI.HtmlTextWriter = New Web.UI.HtmlTextWriter(tw) '写出这个html字段 Response.Write(dst.Tables(0).Rows(0)(0).ToString) Response.End()
TO guoyan19811021(吉祥) ,看不懂你的代码, 我写了如下代码: OleDbConnection myConnection = ………………; //连接数据库 OleDbDataReader reader=null; string sql; sql = "SELECT SYSTEMTITLE,SYSTEMCONTENT FROM T_TrainSafeSystem WHERE ID = '" + Request.QueryString["ID"] + "'"; OleDbCommand cmd = new OleDbCommand(sql,myConnection);
FileStream fs; // Writes the BLOB to a file (*.htm). BinaryWriter bw; // Streams the BLOB to the FileStream object. int bufferSize = 200000; // Size of the BLOB buffer. byte[] outbyte = new byte[bufferSize]; // The BLOB byte[] buffer to be filled by GetBytes. long retval; // The bytes returned from GetBytes. long startIndex = 0; // The starting position in the BLOB output. string pub_id = ""; // The publisher id to use in the file name. // Open the connection and read data into the DataReader. reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess); while (reader.Read()) { // Get the publisher id, which must occur before getting the logo. pub_id = reader.GetString(0); // Create a file to hold the output. fs = new FileStream("制度:" + pub_id + ".htm", FileMode.OpenOrCreate, FileAccess.Write); bw = new BinaryWriter(fs); // Reset the starting byte for the new BLOB. startIndex = 0; // Read the bytes into outbyte[] and retain the number of bytes returned. retval = reader.GetBytes(1, startIndex, outbyte, 0, bufferSize); // Continue reading and writing while there are bytes beyond the size of the buffer. while (retval == bufferSize) { bw.Write(outbyte); bw.Flush(); // Reposition the start index to the end of the last buffer and fill the buffer. startIndex+= bufferSize; retval = reader.GetBytes(1, startIndex, outbyte, 0, bufferSize); } // Write the remaining buffer. bw.Write(outbyte); bw.Flush(); // Close the output file. bw.Close(); fs.Close(); } // Close the reader and the connection. reader.Close(); 执行到 reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess);时出现错误: “不支持此接口发生了一个 Oracle 错误,但无法从 Oracle 中检索错误信息。数据类型不被支持。”请问这是怎么回事?是不是在 相应的FORM里要设置什么属性啊?我在FORM标签里写了 enctype="multipart/form-data" 。我不知道错在哪??请各位指点!!!
http://xml.sz.luohuedu.net/xml/ShowDetail.asp?id=EY1XLDYV-PIDF-43LO-1WFL-FMY5ALE1F635
Dim cmd As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter("select * from 1", conn)
Dim dst As DataSet = New DataSet
cmd.Fill(dst)
Response.Charset = "UTF-8"
Response.AppendHeader("Content-Disposition", "attachment;filename=aa.htm")
Response.ContentEncoding = System.Text.Encoding.Default
Dim tw As System.IO.StringWriter = New System.IO.StringWriter
Dim hw As Web.UI.HtmlTextWriter = New Web.UI.HtmlTextWriter(tw)
'写出这个html字段
Response.Write(dst.Tables(0).Rows(0)(0).ToString)
Response.End()
我写了如下代码:
OleDbConnection myConnection = ………………; //连接数据库
OleDbDataReader reader=null;
string sql;
sql = "SELECT SYSTEMTITLE,SYSTEMCONTENT FROM T_TrainSafeSystem WHERE ID = '" + Request.QueryString["ID"] + "'";
OleDbCommand cmd = new OleDbCommand(sql,myConnection);
FileStream fs; // Writes the BLOB to a file (*.htm).
BinaryWriter bw; // Streams the BLOB to the FileStream object. int bufferSize = 200000; // Size of the BLOB buffer.
byte[] outbyte = new byte[bufferSize]; // The BLOB byte[] buffer to be filled by GetBytes.
long retval; // The bytes returned from GetBytes.
long startIndex = 0; // The starting position in the BLOB output. string pub_id = ""; // The publisher id to use in the file name. // Open the connection and read data into the DataReader.
reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess); while (reader.Read())
{
// Get the publisher id, which must occur before getting the logo.
pub_id = reader.GetString(0); // Create a file to hold the output.
fs = new FileStream("制度:" + pub_id + ".htm", FileMode.OpenOrCreate, FileAccess.Write);
bw = new BinaryWriter(fs); // Reset the starting byte for the new BLOB.
startIndex = 0; // Read the bytes into outbyte[] and retain the number of bytes returned.
retval = reader.GetBytes(1, startIndex, outbyte, 0, bufferSize); // Continue reading and writing while there are bytes beyond the size of the buffer.
while (retval == bufferSize)
{
bw.Write(outbyte);
bw.Flush(); // Reposition the start index to the end of the last buffer and fill the buffer.
startIndex+= bufferSize;
retval = reader.GetBytes(1, startIndex, outbyte, 0, bufferSize);
} // Write the remaining buffer.
bw.Write(outbyte);
bw.Flush(); // Close the output file.
bw.Close();
fs.Close();
} // Close the reader and the connection.
reader.Close(); 执行到 reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess);时出现错误:
“不支持此接口发生了一个 Oracle 错误,但无法从 Oracle 中检索错误信息。数据类型不被支持。”请问这是怎么回事?是不是在 相应的FORM里要设置什么属性啊?我在FORM标签里写了
enctype="multipart/form-data" 。我不知道错在哪??请各位指点!!!
这个问题我碰道了,
试了guoyan19811021(吉祥) ( ) 的方法也不行,
在 “cmd.Fill(dst)”一行提示与 xieyuanmin(成崖余) ( ) 一样的错误----“不支持此接口发生了一个 Oracle 错误,但无法从 Oracle 中检索错误信息。数据类型不被支持。”我感觉是sql语句的问题,放到sql plus里一试说blob类型无法显示,
各位高手谁有什么好办法,
顶!
并添加进了工程,在namespace 还 加了语句 using System.Data.OracleClient ,
但运行时还是出现上面的错误,靠!我真的搞不懂了。是我引用的不对吗?