用byte形式存入
读出后还原成图片
Image类
读出后还原成图片
Image类
解决方案 »
- 根据一个城市的ip跳到不同网站 aspx
- 求一方法,可以把字节单位KB换算成MB
- 关于Google的东西
- 求一字符替换的正则表达!
- 在新闻系统中,如何实现当前位置显示
- 关于语法错误问题(20分)
- 请问asp.net里如何使用C#调用以前VB.net写的类????
- 新手学从access中读数据的总是?
- 我有很多程序都是和教材写的一样。也检查了没有什么错误,可是老不执行呢!?SOS!!!!!!!!!!
- 大家帮帮忙,怎样获取一个TextBox控件中的被用户选取了的字符啊?
- 为什么我通过odbc访问数据库的时候提示ADOConnection没有定义?
- 请问水晶报表如何打印?另:小弟刚来,大家多多指教。
{
case "image/bmp":
if(this.fileLoad.PostedFile.InputStream.Length > 1024000)
//图片大小大于1000kb
{
this.H_Error.Value = "imageSizeError";
}
else
{
Stream imgDataStream = this.fileLoad.PostedFile.InputStream;
int imgDataLenth = this.fileLoad.PostedFile.ContentLength;
byte[] imgDataList = new byte[imgDataLenth];
imgDataStream.Read(imgDataList,0,imgDataLenth);
Session["sImage"] = imgDataList;
Image.ImageUrl = "ShowFile.aspx";
//以上实在web窗体中显示图片,下面是保存到数据库中
string updateSql = "Select from unformatdata where ID = " + Session["sID"].ToString();
//创建sqlCommand对象
string conString = "server = (local);database = pratice;user id = sa; pwd = ";
SqlConnection myConnection = new SqlConnection(conString);
SqlCommand myCommand = new SqlCommand(updateSql,myConnection);
myCommand.Connection.Open();
try
{
SqlDataAdapter MyAdapter=new SqlDataAdapter();
SqlCommandBuilder Var_SqlCB;
MyAdapter.SelectCommand=myCommand;
Var_SqlCB = new SqlCommandBuilder(MyAdapter);
DataSet myDataSet=new DataSet();
MyAdapter.Fill(myDataSet,"myTable");
myDataSet.Tables["myTable"].Rows[0]["Unfordata"] = (byte[])imgDataList;
myDataSet.Tables["myTable"].Rows[0]["Type"] = "bmp图像";
myDataSet.Tables["myTable"].Rows[0]["Size"] = imgDataLenth;
MyAdapter.Update(myDataSet,"myTable");
}
catch(Exception ex)
{
System.Console.WriteLine(ex.Message.ToString());
}
myCommand.Connection.Close(); DataGrid1.DataSource = fillDT();
DataGrid1.DataBind();
}
break;
//类似的还可以添加声音、动画、word等
//读出代码如下:
switch(dataType)
{
case("bmp图像"):
Session["FileType"] = "image/bmp";
Session["sImage"] = chooseDataLine["Unfordata"];
this.Image.ImageUrl = "ShowFile.aspx";
break;
//类似的可以显示其他数据