(@srvtitle,@csttitle,@introduction,@logo " /> 日韩欧美视频专区,日韩电影一区,亚洲同志男男gay1069网站

色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

asp.net 圖片的讀寫入庫實現代碼

寫圖片c:/1.jpg到表cinfo中
復制代碼 代碼如下:
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 = "旅業互動";
parms[1].Value = "lyhd";
parms[2].Value = "簡介";

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);
}

讀取圖片的頁面 test.ASPx
復制代碼 代碼如下:
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);
}
}

用來顯示圖片的頁面 test2.ASPx
復制代碼 代碼如下:
<img src="test.ASPx" />

AspNet技術asp.net 圖片的讀寫入庫實現代碼,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 华池县| 延边| 隆昌县| 玛多县| 墨竹工卡县| 巴彦淖尔市| 丰都县| 白水县| 巴中市| 焉耆| 米易县| 高要市| 搜索| 蒙自县| 梓潼县| 金阳县| 尉犁县| 依安县| 揭东县| 合江县| 木里| 西乌| 临猗县| 阳城县| 清涧县| 宝兴县| 巨野县| 冀州市| 蒲城县| 金乡县| 蒙城县| 翼城县| 金阳县| 徐汇区| 大邑县| 米林县| 临汾市| 获嘉县| 三亚市| 台中县| 克山县|