ASP.NET´ÓSQL ServerÊý¾Ý¿âÌáȡͼƬ²¢ÏÔʾÔÚDataGrid
ʹÓÃGridview°ó¶¨Êý¾Ý¿âÖеÄͼƬ(תÔØ)
×¢£º´ËϵÁмǼÔÚÎÒʵ¼Ê¿ª·¢ÖÐÓöµ½µÄÎÊÌâºÍÊÕ²ØһЩ¼¼ÇÉÎÄÕ¡£
ÎÒÃǶ¼ÖªµÀ£¬ÔÚGridviewÖв»ÄÜÖ±½ÓÈ¥°ó¶¨Êý¾Ý¿âÖеÄͼƬ£¬ÎÒÃÇ¿ÉÒÔÀûÓÃHttpHandlerºÜÈÝÒ×µÄÍê³ÉÕâ¸öÈÎÎñ£¬ÔÚÕâÀïÎҼǼһÏÂÕâ¸ö¹ý³Ì¡£
1.ÉÏ´«Í¼Æ¬´æ´¢µ½Êý¾Ý¿âÖÐ
ÔÚÊý¾Ý¿âÖд´½¨Ò»¸ö±í£¬Ìí¼ÓÒ»ÏÂ3¸ö×ֶΣº
²½ÖèÒ»£ºÔÚWebÒ³ÃæÖÐÍÏÒ»¸öFileUpload ¿Ø¼þ£¬Ò»¸öÎı¾¿òÓÃÓÚÊäÈëÃû³ÆºÍÌá½»ÉÏ´«°´Å¥
<asp:FileUpload ID="fuImage" runat="server" /><br />
<asp:TextBox ID="txtImageName" runat="server"/><br />
<asp:Button ID="btnUpload" runat="server" onClick="btnUpload_Click" Text="Upload" />
²½Öè¶þ£ºÔÚWeb.ConfigÎļþÄÚÅäÖÃÁ¬½Ó×Ö·û´®¡£
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;
AttachDbFilename=|DataDirectory|\Image.mdf;Integrated Security=True;
User Instance=True" providerName="System.Data.SqlClient"/>
²½ÖèÈý£º°ÑÏÂÃæµÄ´úÂ븴ÖƵ½ÉÏ´«°´Å¥Ê¼þÖС£
protected void btnUpload_Click(object sender, EventArgs e)
{
Stream imgStream = fuImage.PostedFile.InputStream;
int imgLen = fuImage.PostedFile.ContentLength;
string imgName = txtImageName.Text;
byte[] imgBinaryData = new byte[imgLen];
int n = imgStream.Read(imgBinaryData,0,imgLen);
//use the web.config to store the connection string
SqlConnection connection = new SqlConnection(ConfigurationManager.
ConnectionStrings["connectionString"].ConnectionString);
SqlCommand command = new SqlCommand("INSERT INTO Image (imagename,image)
VALUES ( @img_name, @img_data)", connection);
SqlParameter param0 = new SqlParameter("@img_name", SqlDbType.VarChar, 50);
param0.Value = imgName;
command.Parameters.Add(param0);
SqlParameter param1 = new SqlParameter("@img_data", SqlDbType.Image);
param1.Value = imgBinaryData;
command.Parameters.Add(param1);
connection.Open();
int numRowsAffected = command.ExecuteNonQuery();
connection.Close();
}
2.ÀûÓÃHttpHandler´ÓÊý¾Ý¿âÖжÁȡͼƬ
´´½¨
Ïà¹ØÎĵµ£º
Sql´úÂë
--²ÉÓÃSQLÓï¾äʵÏÖsql2005ºÍExcel Êý¾ÝÖ®¼äµÄÊý¾Ýµ¼Èëµ¼³ö£¬ÔÚÍøÉÏÕÒÀ´Ò»--Ï£¬ÊµÏÖ·½·¨ÊÇÕâÑùµÄ£º
--Excel---->SQL2005 µ¼È룺
select * into useinfo from O ......
1.´ò¿ªSQL server enterprise mananger “ÆóÒµ¹ÜÀíÆ÷”
ÔÚÄãÒªµ¼³öµÄSQLÊý¾Ý¿âÉÏÊó±êÓÒ¼ü²Ëµ¥£ºËùÓÐÈÎÎñ-¡·µ¼³öÊý¾Ý
2.»Ø³öÏÖÒ»¸öµ¼³öÏòµ¼´°¿Ú¡£
Ñ¡Ôñ±»µ¼³öµÄÊý¾ÝÔ´£¬ÎªÄã¸Õ²ÅËùÑ¡ÔñµÄÊý¾Ý¿â£¬Èç¹û·¢ÏÖ²»¶ÔÓ¦×ÔÐÐÐ޸ġ£
3.½øÈëµ¼³öµ½Ä¿±êÊý¾ÝÔ´µÄÑ¡Ôñ£¬ÕâÀïÎÒÃÇҪת³ÉACCESSµÄÊý¾Ý¿â¡£×¢ÒâÑ¡ÔñÊý¾ÝÔ´ÀàÐÍÎ ......
µÚÒ»ÖÖ·½·¨£º
ͨ¹ýURLÁ´½ÓµØÖ·´«µÝ
send.aspx:
protected void Button1_Click(object sender, EventArgs e)
{
Request.Redirect("Default2.aspx?username=honge");
}
receive.aspx:
string user ......
/// <summary>
/// µÃµ½Õ¾µãÓû§IP
/// </summary>
/// <returns></returns>
public
static
string
getUserIP()
{
retu ......
ÔÚ×î½üµÄÓÃasp.net ¿ª·¢µÄÏîÄ¿ÖУ¬×öÓÅ»¯£¬Òª°ÑÒ³Ã澲̬»¯£¬²éÁ˺ܶàÖÖ·½·¨£¬×îºóÑ¡ÔñÁËÓÃÄ£°åÀ´ÊµÏÖ£¬
×îÖÕÒ³µÄʵÏֱȽϼòµ¥£¬ÔÚÍøÉÏÕÒÁËÒ»¶Î´úÂ룬µ«Ê×Ò³£¬¶þ¼¶Ò³£¬ÁбíÒ³µÄ´¦Àí±¾ÈËÊÇÓõÄÒÔÏ·½°¸£¬ÏÖÔÚ»¹Ö»ÊÇÒ»¸ö±È½Ï¼òµ¥µÄ£¬Ï£ÍûÓдó¼Ò¶à¶àÖ¸µã£¬½»Á÷£»
·½·¨ÈçÏ£º
˼·ÃèÊö£º
1£ ......