sele="SELECT result1 FROM IWCResult1,IWCResult2 WHERE (ResultID = 386)";
Object yy;
try
{
string myConnectionString="Data Source=192.168.10.05; user id=sa; password=password;database=InstaFormContent";
SqlConnection sqlConnection1 = new SqlConnection(myConnectionString); sqlConnection1.Open();
SqlCommand sqlSelectCommand1=new SqlCommand (sele,sqlConnection1 );
//读取image类型数据为byte[],IWCResult1,IWCResult2 为image类型
sqlConnection1.Close();
sele=null;
}
catch
{
MessageBox.Show("c");
}
Object yy;
try
{
string myConnectionString="Data Source=192.168.10.05; user id=sa; password=password;database=InstaFormContent";
SqlConnection sqlConnection1 = new SqlConnection(myConnectionString); sqlConnection1.Open();
SqlCommand sqlSelectCommand1=new SqlCommand (sele,sqlConnection1 );
//读取image类型数据为byte[],IWCResult1,IWCResult2 为image类型
sqlConnection1.Close();
sele=null;
}
catch
{
MessageBox.Show("c");
}
try
{
string myConnectionString="Data Source=192.168.10.05; user id=sa; password=password;database=InstaFormContent";
SqlConnection sqlConnection1 = new SqlConnection(myConnectionString); sqlConnection1.Open();
SqlCommand sqlSelectCommand1=new SqlCommand (sele,sqlConnection1 );
//读取image类型数据为byte[],IWCResult1,IWCResult2 为image类型,怎么读取??
sqlConnection1.Close();
sele=null;
}
catch
{
MessageBox.Show("c");
}
DataSet ds=new DataSet();
da.Fill(ds,"image");
byte [] mybyte=(byte[])ds.Tables[0].Rows[0]["pic"];
我这样
byte[] bFile=new byte[Convert.ToInt32(reader.GetBytes(0,0,null,0,Int32.MaxValue))];
//将数据读进数组
reader.GetBytes(0,0,bFile,0,bFile.Length);
也不行,为什么?
从数据库里读出来没有错,只是赋给byte[]时就不可以了。