//存入数据
byte[] imagebytes=null;
FileStream fs=new FileStream(filepath,fileMode.Open);
BinaryReader br=new BinaryReader(fs);
imagebytes=br.ReadBytes(Maxsize);
imageCommand.CommandText=
"insert into imagetable values(@imagefile,@imageData)";
imageCommand.Parameters.Add("@imagefile",SqlDbType.NVarChar);
imageCommand.Parameters.Add("@imagedata",SqlDbType.Image);
imageCommand.Parameters["@imagefile"].Value=imagefilename;
imageCommand.Parameters["@imagedata"].Value=imagedata;
imageCommand.ExecuteNonQuery();
//读取数据
imageCommand.CommandText=
"select imagefile,imagedata from imagetable";
imagereader=imageCommand.ExecuteReader();
imagefilename=(string)imagereader.GetValue(0);
imagebytes=(byte[])imagereader.GetValue(1);
MemoryStream ms=new MemoryStream(imagebytes);
Bitmap bmap=new Bitmap(ms
byte[] imagebytes=null;
FileStream fs=new FileStream(filepath,fileMode.Open);
BinaryReader br=new BinaryReader(fs);
imagebytes=br.ReadBytes(Maxsize);
imageCommand.CommandText=
"insert into imagetable values(@imagefile,@imageData)";
imageCommand.Parameters.Add("@imagefile",SqlDbType.NVarChar);
imageCommand.Parameters.Add("@imagedata",SqlDbType.Image);
imageCommand.Parameters["@imagefile"].Value=imagefilename;
imageCommand.Parameters["@imagedata"].Value=imagedata;
imageCommand.ExecuteNonQuery();
//读取数据
imageCommand.CommandText=
"select imagefile,imagedata from imagetable";
imagereader=imageCommand.ExecuteReader();
imagefilename=(string)imagereader.GetValue(0);
imagebytes=(byte[])imagereader.GetValue(1);
MemoryStream ms=new MemoryStream(imagebytes);
Bitmap bmap=new Bitmap(ms