(@srvtitle,@csttitle,@introduction,@logo " /> 中文字幕少妇一区二区三区,在线免费观看日韩欧美,欧美一区二区性放荡片

色尼玛亚洲综合影院,亚洲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 圖片的讀寫入庫實現代碼,轉載需保留來源!

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

主站蜘蛛池模板: 长葛市| 东乡族自治县| 阿鲁科尔沁旗| 江北区| 浮梁县| 根河市| 四子王旗| 广安市| 广河县| 明溪县| 漳平市| 江北区| 屏南县| 茌平县| 柳州市| 弥勒县| 改则县| 乌兰浩特市| 江华| 马边| 伊川县| 永兴县| 富锦市| 娄底市| 临江市| 阿拉尔市| 新乡县| 屯留县| 沁水县| 开江县| 肇源县| 资源县| 海林市| 改则县| 博野县| 蕉岭县| 宁远县| 紫金县| 南岸区| 屏山县| 新郑市|