国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > .NET > 正文

asp.net 圖片的讀寫(xiě)入庫(kù)實(shí)現(xiàn)代碼

2020-01-18 01:06:15
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
寫(xiě)圖片c:/1.jpg到表cinfo中
復(fù)制代碼 代碼如下:

private static void AddCinfo()
{
string strSql = "insert into cinfo (srvtitle,csttitle,introduction,logo) values

(@srvtitle,@csttitle,@introduction,@logo)";
SqlParameter[] parms =
{
new SqlParameter("@srvtitle",SqlDbType.VarChar,30),
new SqlParameter("@csttitle",SqlDbType.VarChar,30),
new SqlParameter("@introduction",SqlDbType.NVarChar,500),
new SqlParameter("@logo",SqlDbType.Image)
};
parms[0].Value = "旅業(yè)互動(dòng)";
parms[1].Value = "lyhd";
parms[2].Value = "簡(jiǎn)介";

string filePath = @"c:/1.jpg";
FileStream fs = File.OpenRead(filePath);

byte[] content = new byte[fs.Length];

fs.Read(content, 0, content.Length);

fs.Close();

parms[3].Value = content;

DBHelper.ExecuteNonQuery(CommandType.Text, strSql, parms);
}

讀取圖片的頁(yè)面 test.aspx
復(fù)制代碼 代碼如下:

protected void Page_Load(object sender, EventArgs e)
{
string strSql = "select * from cinfo where id=1";
SqlDataReader reader=DBHelper.ExecuteReader(CommandType.Text, strSql, null);
if(reader.Read())
{
byte[] c=(byte[])reader["logo"];
Response.BinaryWrite(c);
}
}

用來(lái)顯示圖片的頁(yè)面 test2.aspx
復(fù)制代碼 代碼如下:

<img src="test.aspx" />
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 区。| 巩留县| 平凉市| 黔南| 犍为县| 简阳市| 紫金县| 华容县| 冀州市| 雅江县| 明星| 双江| 泊头市| 张北县| 甘孜| 中江县| 淄博市| 闻喜县| 滨州市| 瓦房店市| 房山区| 视频| 长白| 昆山市| 牟定县| 博兴县| 宜黄县| 分宜县| 湘阴县| 乳山市| 马山县| 梁平县| 靖西县| 岳阳市| 慈溪市| 桃园县| 龙泉市| 古蔺县| 肥西县| 康保县| 工布江达县|