BLOB [英] blob

查看:65
本文介绍了BLOB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此代码从sql server获取blob,但是我收到错误

参数无效。


SqlDataReader sqlRead = null;


图像配置文件;
db.sqlConnection.Open();


系统。 Data.SqlClient.SqlCommand ProfileBLOBSelect = new

System.Data.SqlClient.SqlCommand();


ProfileBLOBSelect.CommandText =" dbo。[AppProfileSelectIDBLOB]" ;;


ProfileBLOBSelect.CommandType = System.Data.CommandType.StoredProcedure;


ProfileBLOBSelect.Connection = db.sqlConnection;


ProfileBLOBSelect.Parameters.Add(new

System.Data.SqlClient.SqlParameter(" @ RETURN_VALUE",

System.Data.SqlDbType .Int,4,System.Data.ParameterDirection.ReturnValue,

false,((System.Byte)(0)),((System.Byte)(0)),"",

System.Data.DataRowVersion.Current,null));


ProfileBLOBSelect.Parameters.A dd(new

System.Data.SqlClient.SqlParameter(" @ AppProfileID" ,

System.Data.SqlDbType.UniqueIdentifier,16));


ProfileBLOBSelect.Parameters [" @ AppProfileID"]。Value = row.AppProfileID;


sqlRead = ProfileBLOBSelect.ExecuteReader();


if(sqlRead.Read())


{


int iFileSize = sqlRead.GetInt32(3);


Byte [] arBuffer = new Byte [iFileSize];


sqlRead.GetBytes(4,0,arBuffer,0,iFileSize);


Stream str = new MemoryStream(arBuffer);


str.Write(arBuffer,0,iFileSize);


profile = Image.FromStream(str); - >这个是无效的!


str.Close();


}


I''m using this code to get blob from sql server, but I get an error
"Parameter is invalid."

SqlDataReader sqlRead = null;

Image profile;
db.sqlConnection.Open();

System.Data.SqlClient.SqlCommand ProfileBLOBSelect = new
System.Data.SqlClient.SqlCommand();

ProfileBLOBSelect.CommandText = "dbo.[AppProfileSelectIDBLOB]";

ProfileBLOBSelect.CommandType = System.Data.CommandType.StoredProcedure;

ProfileBLOBSelect.Connection = db.sqlConnection;

ProfileBLOBSelect.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@RETURN_VALUE" ,
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue,
false, ((System.Byte)(0)), ((System.Byte)(0)), "",
System.Data.DataRowVersion.Current, null));

ProfileBLOBSelect.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@AppProfileID" ,
System.Data.SqlDbType.UniqueIdentifier, 16));

ProfileBLOBSelect.Parameters["@AppProfileID"].Value = row.AppProfileID;

sqlRead = ProfileBLOBSelect.ExecuteReader();

if (sqlRead.Read())

{

int iFileSize = sqlRead.GetInt32( 3 );

Byte[] arBuffer = new Byte[iFileSize];

sqlRead.GetBytes(4, 0, arBuffer, 0, iFileSize);

Stream str = new MemoryStream(arBuffer);

str.Write(arBuffer, 0, iFileSize);

profile = Image.FromStream(str); --> this one is invalid!

str.Close();

}


推荐答案



" Hrvoje Voda" < HR ********* @ luatech.com>在消息中写道

news:e1 ********** @ ss405.t-com.hr ...

"Hrvoje Voda" <hr*********@luatech.com> wrote in message
news:e1**********@ss405.t-com.hr...
我正在使用此代码从sql server获取blob,但是我收到错误
参数无效。
I''m using this code to get blob from sql server, but I get an error
"Parameter is invalid."




这是我用来从blob获取晶体的代码。

我没有时间分析你的代码,但我希望这会对你有所帮助。


{

string SQLappend ="" ;;

const string cQRY =" not so important" ;;

DataSet DST = new DataSet(" Crep_BLOB" ;);

byte [] Arr_cRep = new byte [0];

DataRow DRow;


SqlDataAdapter SDA = new SqlDataAdapter (SQLappend,Conn);

SqlCommandBuilder CBuild = new SqlCommandBuilder(SDA);

SDA.Fill(DST," Crep_BLOB"); //表名


DRow = DST.Tables [" Crep_BLOB"]。行[0];

Arr_cRep =(byte [])DRow [ " crepdefault"];

int ArraySize = new int();

ArraySize = Arr_cRep.GetUpperBound(0);

FileStream FStream = new

FileStream(@" c:\ cRep_Temp \ tReport.rpt",FileMode.OpenOrCreate,

FileAccess.Write);

FStream.Write(Arr_cRep,0,ArraySize);

FStream.Close();

FStream.Dispose();

DRow。删除();

}



This is code i use for getting crystals from blob.
I have not enaugh time for analysing your code but I hope so this will help
you.

{
string SQLappend="";
const string cQRY = "not so important";
DataSet DST = new DataSet("Crep_BLOB");
byte[] Arr_cRep = new byte[0];
DataRow DRow;

SqlDataAdapter SDA = new SqlDataAdapter(SQLappend, Conn);
SqlCommandBuilder CBuild = new SqlCommandBuilder(SDA);
SDA.Fill(DST, "Crep_BLOB"); //table name

DRow = DST.Tables["Crep_BLOB"].Rows[0];
Arr_cRep = (byte[])DRow["crepdefault"];
int ArraySize = new int();
ArraySize = Arr_cRep.GetUpperBound(0);
FileStream FStream = new
FileStream(@"c:\cRep_Temp\tReport.rpt", FileMode.OpenOrCreate,
FileAccess.Write);
FStream.Write(Arr_cRep, 0, ArraySize);
FStream.Close();
FStream.Dispose();
DRow.Delete();
}


这篇关于BLOB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆