如
byte[] bt;
bt=(byte[])reader.GetValue(0);//这是读ole
byte[] bt;
bt=(byte[])reader.GetValue(0);//这是读ole
解决方案 »
- 如何修改51aspx权限啊,求大神们帮帮忙。
- WPF的RichTextBox如何赋值给它
- 怎样用GDI+ 将两个已知圆点,半径的圆连接起来?难点在于不是连接圆心而是要通过圆的边进行连接
- 下面代码g.DrawImage(Image.FromFile(files[i]),i%3*120,i/3*120,100,100)会内存不足是什么原因?
- statusStrip1上的toolStripStatusLabel1如何右对齐?
- DLL组件安装注册,急! 各位大侠救急
- (急,在线等),如何在wiform中显示一个文件夹中所有图片的缩略图
- 那有xde for net2003?
- 菜鸟问题,在程序开始执行时如何让TREEVIEW定位在第一个子节点上
- C# avicap32摄像头录像界面卡死问题(8年悬而未决)
- 请教一简单问题,谢谢
- 怎样往数据库OLE字段里插入文件
必须先使用这种方法进行插入,然后才读出,不能先使用ACCESS功能插入,然后读出.
这可是本人研究成果哟!
private void btnShow_Click(object sender, System.EventArgs e)
{
string SQL="SELECT * FROM test1 ";
string ConnectionString = " Provider=Microsoft.Jet.OLEDB.4.0;Data Source = E:\\myvc\\testdb.mdb";
OleDbConnection conn=new OleDbConnection(ConnectionString);
OleDbCommand cmd=conn.CreateCommand();
cmd.CommandText=SQL;
conn.Open();
OleDbDataReader dr=cmd.ExecuteReader(); if(dr.Read())
{
string strFile=string.Empty;
strFile=dr.GetString(1);
byte[] by=(byte[])dr.GetValue(2); MemoryStream mss = new MemoryStream(by); this.picImage.Image = Image.FromStream(mss);
}
dr.Close();
conn.Close();}private void btnExit_Click(object sender, System.EventArgs e)
{
Dispose(true);
}private void btnSearch_Click(object sender, System.EventArgs e)
{
Bitmap MyImage ;
string fileToDisplay = "";
OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.InitialDirectory = "c:\\" ;
openFileDialog1.Filter = "bmp files (*.bmp)|*.bmp|jpg files (*.jpg)|*.jpg|gif files (*.gif)|*.gif" ;
openFileDialog1.FilterIndex = 3 ;
openFileDialog1.RestoreDirectory = true ; if(openFileDialog1.ShowDialog() == DialogResult.OK)
{
fileToDisplay = openFileDialog1.FileName; // Stretches the image to fit the pictureBox.
picImage.SizeMode = PictureBoxSizeMode.StretchImage ;
MyImage = new Bitmap(fileToDisplay);
picImage.Image = (Image) MyImage ;
}}private void btnSave_Click(object sender, System.EventArgs e)
{
string SQL="SELECT * FROM test1 ID = 8";
string ConnectionString = " Provider=Microsoft.Jet.OLEDB.4.0;Data Source = E:\\myvc\\testdb.mdb";
try
{ OleDbConnection conn=new OleDbConnection(ConnectionString);
OleDbDataAdapter da=new OleDbDataAdapter(SQL,conn);
OleDbCommandBuilder cmd=new OleDbCommandBuilder(da);
DataSet ds=new DataSet(); conn.Open();
da.Fill(ds,"test1");
DataTable dt=ds.Tables[0];
DataRow dr;
if(dt.Rows.Count>0)
dr=dt.Rows[0];
else
dr=dt.NewRow(); dr[1]=txtName.Text;
MemoryStream ms = new MemoryStream ();
picImage.Image.Save (ms, System.Drawing.Imaging.ImageFormat.Bmp);
byte [] myData = new Byte [ms.Length ]; ms.Position = 0;
ms.Read (myData,0,Convert.ToInt32 (ms.Length ));
dr[2] = myData; if(dt.Rows.Count<=0)
dt.Rows.Add(dr);
da.Update(ds, "test1"); conn.Close();
MessageBox.Show("Bmp File Save Success!");
}
catch(System.Exception ee)
{
MessageBox.Show(ee.Message);
}
}