我建了个access数据库,
字段:ID(long),图片名(string),图片实体(不知道什么类型?在oracle里为blob,可在这个里面我不知道是什么了)每次选择一个图片,读成二进制保存到数据库,可不知道图片实体字段为什么类型?
还请大家提示一下。
字段:ID(long),图片名(string),图片实体(不知道什么类型?在oracle里为blob,可在这个里面我不知道是什么了)每次选择一个图片,读成二进制保存到数据库,可不知道图片实体字段为什么类型?
还请大家提示一下。
调试欢乐多
da.Fill(ds, "MyImages");
DataRow myRow;
myRow=ds.Tables["MyImages"].Rows[0];
MyData = (byte[])myRow["imgField"];
int ArraySize = new int();
ArraySize = MyData.GetUpperBound(0); FileStream fs = new FileStream(@"C:\winnt\Gone Fishing2.BMP", FileMode.OpenOrCreate, FileAccess.Write);
fs.Write(MyData, 0,ArraySize);
fs.Close();
我先试一下
http://blog.csdn.net/knight94/archive/2006/03/24/637800.aspx
byte[] MyData= new byte[0];
DataSet ds = new DataSet();
pDataAdpter.Fill(ds, "TEST");
DataRow myRow;
myRow=ds.Tables["tEST"].Rows[0];
MyData = (byte[])myRow["FileData"];
int ArraySize = new int();
ArraySize = MyData.GetUpperBound(0); FileStream fs = new FileStream(@"C:\1.gif", FileMode.OpenOrCreate, FileAccess.Write);
fs.Write(MyData, 0,ArraySize);
fs.Close();在“MyData = (byte[])myRow["FileData"];”处,执行总是出错,因为我的filedata字段是空的?//////////////////////////////////////////////////////////
我的TEST表结构是
id:自增
filedata :ole对象
filename :文本目前表里有2条记录,但2条记录里只有fiename有值,filedata没值,这段程序我该怎么改呢?望高手指点!
if ( fi.Exists)
{
byte[] bData = null;
using ( FileStream fs = fi.OpenRead())
{
bData = new byte[fi.Length];
int nReadLength = fs.Read( bData,0, (int)(fi.Length) );
}
string strQuery = "INSERT INTO TEST "
+ " ( FILEDATA) "
+ " VALUES "
+ " (:FILEDATA_) ";
OdbcCommand OdbcComm = new OdbcCommand( strQuery,ClsDbService.GetConn);// OdbcParameter pFileNamePara = new OdbcParameter("FileName_",OdbcType.VarChar);
// pFileNamePara.Direction = ParameterDirection.Input;
// pFileNamePara.Value = "af";
OdbcParameter pFileDataPara = new OdbcParameter("FILEDATA_",OdbcType.Image);
pFileDataPara.Direction = ParameterDirection.Input;
pFileDataPara.Value = bData; //OdbcComm.Parameters.Add(pFileNamePara);
OdbcComm.Parameters.Add(pFileDataPara);
OdbcComm.ExecuteNonQuery();
ClsDbService.ExecuteNonQuery("Commit");
望高手帮看看
是什么意思?
paramPersonImage.Value = fileData;
command.Parameters.Add(paramPersonImage);
请问一下,对应的表中的PersonImage字段的类型是什么??是ole对象吗??
保存的时候总出错:ERROR [HY104] [Microsoft][ODBC Microsoft Access Driver]非法的精确度数值