asp如何读取ACCESS中的OLE对象,非图片 我把rar等非图片文件上传到access数据库中,保存为OLE对象,现在想在一个页面上把这些文件列出来,然后别人点击就能下载,就像软件下载一样,请高手指点 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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); } }下载的时候是二进制下载么。其实存路径比较好些。 web.config 中加入<configuration><system.web><httpRuntime maxRequestLength="1048576" executionTimeout="3600" /></system.web></configuration> Web.config memoryLimit:<configuration><system.web><processModel memoryLimit="80"/></system.web></configuration> 难道你不看标题,不是讲asp的 如何使用treeview控件调用方法在gridview中显示内容 MVC存储过程分页 Html控件和Server端的控件到底如何配合使用... asp.net 2005 可以获取html页面内表单提交过来的值吗,请帮我看一下这段代码? 打印的问题 求教:如何将一个二维数组放入一个ViewState中??为什么一维数组可以,多维数组不行啊? 特急的问题:在.net中关于Oracle数据库的连接,特急,谢先! 有关FORM的问题 sqlserver连接问题 玩过UDDI的请进来看下,问题到底出在哪? 如何在C#中给前台有规律的input赋值 控件的事件发生器问题
{ 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);
}
}下载的时候是二进制下载么。其实存路径比较好些。
web.config 中加入
<configuration>
<system.web>
<httpRuntime maxRequestLength="1048576" executionTimeout="3600" />
</system.web>
</configuration>
Web.config memoryLimit:
<configuration>
<system.web>
<processModel memoryLimit="80"/>
</system.web>
</configuration>