最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
用ado.net对word,excel进行存取
时间:2022-06-30 10:20:42 编辑:袖梨 来源:一聚教程网
blob表
3 id int 4 0
0 name char 50 1
0 blob image 16 1
0 type char 60 1
saveFile.aspx.cs
private void Button1_Click(object sender, System.EventArgs e)
{
Stream imgdatastream = File1.PostedFile.InputStream;
int imgdatalen = File1.PostedFile.ContentLength;
string imgtype = File1.PostedFile.ContentType;
string name = this.getFileNameByURL(this.File1.PostedFile.FileName);
byte[] imgdata = new byte[imgdatalen];
int n = imgdatastream.Read(imgdata,0,imgdatalen);
string connstr = "workstation id=OVERMIND;packet size=4096;user id=sa;password=sa;data source=OVERMIND;persist security info=False;initial catalog=wztj";
SqlConnection connection = new SqlConnection(connstr);
SqlCommand command = new SqlCommand("INSERT INTO blob(name,type,blob) VALUES ( @imgtitle, @type,@blob )", connection );
SqlParameter paramTitle = new SqlParameter("@imgtitle", SqlDbType.VarChar,50 );
paramTitle.Value = name;
command.Parameters.Add(paramTitle);
SqlParameter paramData = new SqlParameter( "@blob", SqlDbType.Image );
paramData.Value = imgdata;
command.Parameters.Add( paramData );
SqlParameter paramType = new SqlParameter( "@type", SqlDbType.VarChar,50 );
paramType.Value = imgtype;
command.Parameters.Add( paramType );
wztj.debug.TestSQL.TraceErrorSql("INSERT INTO blob(name,type,blob) VALUES ( @imgtitle, @type,@blob )",command.Parameters);
connection.Open();
int numRowsAffected = command.ExecuteNonQuery();
connection.Close();
}
listFile.aspx//这个东西主要用来列表,把已经有的东西列出来
3 id int 4 0
0 name char 50 1
0 blob image 16 1
0 type char 60 1
saveFile.aspx.cs
private void Button1_Click(object sender, System.EventArgs e)
{
Stream imgdatastream = File1.PostedFile.InputStream;
int imgdatalen = File1.PostedFile.ContentLength;
string imgtype = File1.PostedFile.ContentType;
string name = this.getFileNameByURL(this.File1.PostedFile.FileName);
byte[] imgdata = new byte[imgdatalen];
int n = imgdatastream.Read(imgdata,0,imgdatalen);
string connstr = "workstation id=OVERMIND;packet size=4096;user id=sa;password=sa;data source=OVERMIND;persist security info=False;initial catalog=wztj";
SqlConnection connection = new SqlConnection(connstr);
SqlCommand command = new SqlCommand("INSERT INTO blob(name,type,blob) VALUES ( @imgtitle, @type,@blob )", connection );
SqlParameter paramTitle = new SqlParameter("@imgtitle", SqlDbType.VarChar,50 );
paramTitle.Value = name;
command.Parameters.Add(paramTitle);
SqlParameter paramData = new SqlParameter( "@blob", SqlDbType.Image );
paramData.Value = imgdata;
command.Parameters.Add( paramData );
SqlParameter paramType = new SqlParameter( "@type", SqlDbType.VarChar,50 );
paramType.Value = imgtype;
command.Parameters.Add( paramType );
wztj.debug.TestSQL.TraceErrorSql("INSERT INTO blob(name,type,blob) VALUES ( @imgtitle, @type,@blob )",command.Parameters);
connection.Open();
int numRowsAffected = command.ExecuteNonQuery();
connection.Close();
}
listFile.aspx//这个东西主要用来列表,把已经有的东西列出来
相关文章
- 哈利波特魔法觉醒拼图寻宝格兰芬多塔楼线索位置攻略 08-01
- 金铲铲之战中秋挑战活动怎么玩?中秋双人大作战玩法介绍 08-01
- 《魔法少女小圆MagiaExedra》月卡可获取奖励一览 08-01
- 《地下城堡4》军团战通关攻略 08-01
- 《地下城堡4》惊悸荒野小屋解密攻略 08-01
- 币圈三大主流交易所详解 币安 Coinbase 火币对比分析 08-01