what data provider are you using?if you are using ODP.NET, seeHow to: Read and Write BLOB Data to a Database Table Through an Anonymous PL/SQL Block
http://www.oracle.com/technology/sample_code/tech/windows/odpnet/howto/anonyblock/index.html
http://www.oracle.com/technology/sample_code/tech/windows/odpnet/howto/anonyblock/index.html
解决方案 »
- java的Vector类型asp.net接收后如何进行类型的转换
- 关于母版页的问题
- 转让自用服务器,或分租托管费,价优从速
- js 改变了服务器控件的值,在服务器端为什么取不到?
- sql连接问题
- 关于程序在图片上画热点的问题.
- 50分求SmartCilent的例子!
- 双11的求助!!!!!!求助!!!!!!求助!!!!!!
- 编译时没有问题,浏览时报的错误CS1595: 已在多处定义IntelligentOffice.Desktop._Default
- 为什么我的ASP.NET工程很多页面都用不了javascript,新建一个工程又没有问题。解決問題給500分,不給是四只腳的!!
- 请各位大侠帮忙!!!(急!急!急) 50分相送
- 我想把一DataGrid内容打印出来。button内容该如果去写?谢谢!DataGrid和Button在同一个页面里面。
下面是我的原代码和报错信息:希望能在百忙之中帮帮忙!!!谢谢!!!OleDbConnection mycon=new OleDbConnection(Base.Base.getConnectionString());
mycon.Open();
da.SelectCommand= new System.Data.OleDb.OleDbCommand("select ZDH,TH from lstowngkcx.T1 where ZDH='"+txt1.Text.Trim()+"'",mycon);
da.Fill(ds,"lstowngkcx.T1");
dv1=new System.Data.DataView(ds.Tables["lstowngkcx.T1"]);
if (dv1.Count > 0)
{
this.DR1 =this.dv1[0].Row;
if(!Information.IsDBNull(RuntimeHelpers.GetObjectValue(this.DR1["TH"]))) { this.Response.BinaryWrite(((byte[]) this.DR1["TH"]));
}
else
{
Response.Write("暂无图片");
}
}
else
{
Response.Write("暂无图片");
} mycon.Close();
未指定的错误发生了一个 Oracle 错误,但无法从 Oracle 中检索错误信息。数据类型不被支持。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.OleDb.OleDbException: 未指定的错误发生了一个 Oracle 错误,但无法从 Oracle 中检索错误信息。数据类型不被支持。源错误:
行 42: da.Fill(ds,"lstowngkcx.T1");
从oracle中取图片,并显示
Dim conn As New OracleClient.OracleConnection()
Dim cmd As New OracleClient.OracleCommand()
Dim myReader As OracleClient.OracleDataReader
Dim sql As String
Dim fl As File sql = "select jt from sd_gtzp" '从数据库中取出图片数据 blob
conn.ConnectionString = "Password=jlsbgis;User ID=jlsbgis;Data Source=sj"
cmd.CommandText = sql
cmd.Connection = conn conn.Open()
myReader = cmd.ExecuteReader(CommandBehavior.SequentialAccess)
myReader.Read() Dim fs As FileStream ' Writes the BLOB to a file (*.bmp).
Dim bw As BinaryWriter ' Streams the binary data to the FileStream object.
Dim bufferSize As Integer = 1000 ' The size of the BLOB buffer.
Dim outbyte(bufferSize - 1) As Byte ' The BLOB byte() buffer to be filled by GetBytes.
Dim retval As Long ' The bytes returned from GetBytes.
Dim startIndex As Long = 0 ' The starting position in the BLOB output.
Dim fpath As String fpath = Server.MapPath(Request.ApplicationPath) & "\Image\photo.bmp" '将图片数据存成本地文件
fs = New FileStream(fpath, FileMode.OpenOrCreate, FileAccess.Write)
bw = New BinaryWriter(fs) ' Reset the starting byte for a new BLOB.
startIndex = 0 ' Read bytes into outbyte() and retain the number of bytes returned.
retval = myReader.GetBytes(0, startIndex, outbyte, 0, bufferSize) ' Continue reading and writing while there are bytes beyond the size of the buffer.
Do While retval = bufferSize
bw.Write(outbyte)
bw.Flush()
' Reposition the start index to the end of the last buffer and fill the buffer.
startIndex = startIndex + bufferSize
retval = myReader.GetBytes(0, startIndex, outbyte, 0, bufferSize)
Loop ' Write the remaining buffer.
bw.Write(outbyte)
bw.Flush()
' Close the output file.
bw.Close()
fs.Close() ' Close the reader and the connection.
myReader.Close()
conn.Close() Dim logo As Image '文件格式转换
logo = Image.FromFile(fpath)
fpath = Server.MapPath(Request.ApplicationPath) & "\Image\zkjhy.jpeg"
logo.Save(fpath, System.Drawing.Imaging.ImageFormat.Jpeg)
Me.Image1.Width = New Unit(300) '调整显示大小
Me.Image1.Height = New Unit(350)
Me.Image1.ImageUrl = "image/zkjhy.jpeg"
System.Byte[] FileByteArray = new System.Byte[UploadFile.PostedFile.ContentLength];
System.IO.Stream StreamObject = UpFile.InputStream;
StreamObject.Read(FileByteArray,0,UploadFile.PostedFile.ContentLength);
OleDbConnection mycon=new OleDbConnection(Base.Base.getConnectionString());//路径
System.String SqlCmd = "INSERT INTO T1 (ZDH,TH) VALUES (?,?)";
System.Data.OleDb.OleDbCommand OleDbCmdObj = new System.Data.OleDb.OleDbCommand(SqlCmd, mycon);
OleDbCmdObj.Parameters.Add("@ZDH", System.Data.OleDb.OleDbType.VarChar,50).Value = txt1.Text;
OleDbCmdObj.Parameters.Add("@TH", System.Data.OleDb.OleDbType.LongVarBinary,UploadFile.PostedFile.ContentLength).Value =FileByteArray;
mycon.Open();
OleDbCmdObj.ExecuteNonQuery();
mycon.Close();