.NetÔÚSqlServerÖеÄͼƬ´æÈ¡¼¼Êõ
±¾ÎÄ×ܽáÈçºÎÔÚ.Net WinformºÍ.Net webform(asp.net)Öн«Í¼Æ¬´æÈësqlserverÖв¢¶ÁÈ¡ÏÔʾµÄ·½·¨
1£¬Ê¹ÓÃasp.net½«Í¼Æ¬ÉÏ´«²¢´æÈëSqlServerÖУ¬È»ºó´ÓSqlServerÖжÁÈ¡²¢ÏÔʾ³öÀ´
Ò»£¬ÉÏ´«²¢´æÈëSqlServer
Êý¾Ý¿â½á¹¹
create table test
{
id identity(1,1),
FImage image
}
Ïà¹ØµÄ´æ´¢¹ý³Ì
Create proc UpdateImage
(
@UpdateImage Image
)
As
Insert Into test(FImage) values(@UpdateImage)
GO
ÔÚUpPhoto.aspxÎļþÖÐÌí¼ÓÈçÏÂ:
<input id="UpPhoto" name="UpPhoto" runat="server" type="file">
<asp:Button id="btnAdd" name="btnAdd" runat="server" Text="ÉÏ´«"></asp:Button>
È»ºóÔÚºóÖôúÂëÎļþUpPhoto.aspx.csÌí¼ÓbtnAdd°´Å¥µÄµ¥»÷ʼþ´¦Àí´úÂë:
private void btnAdd_Click(object sender, System.EventArgs e)
{
//»ñµÃͼÏó²¢°ÑͼÏóת»»Îªbyte[]
HttpPostedFile upPhoto=UpPhoto.PostedFile;
int upPhotoLength=upPhoto.ContentLength;
byte[] PhotoArray=new Byte[upPhotoLength];
Stream PhotoStream=upPhoto.InputStream;
PhotoStream.Read(PhotoArray,0,upPhotoLength);
//Á¬½ÓÊý¾Ý¿â
SqlConnection conn=new SqlConnection();
conn.ConnectionString="Data Source=localhost;Database=test;User Id=sa;Pwd=sa";
SqlCommand cmd=new SqlCommand("UpdateImage",conn);
cmd.CommandType=CommandType.StoredProcedure;
cmd.Parameters.Add("@UpdateImage",SqlDbType.Image);
cmd.Parameters["@UpdateImage"].Value=PhotoArray;
//Èç¹ûÄãÏ£Íû²»Ê¹Óô洢¹ý³ÌÀ´Ìí¼ÓͼƬ°ÑÉÏÃæËľä´úÂë¸ÄΪ£º
//string strSql="Insert into test(FImage) values(@FImage)";
//SqlCommand cmd=new SqlCommand(strSql,conn);
//cmd.Parameters.Add("@FImage",SqlDbType.Image);
//cmd.Parameters["@FImage"].Value=PhotoArray;
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
¶þ£¬´ÓSqlServerÖжÁÈ¡²¢ÏÔʾ³öÀ´
ÔÚÐèÒªÏÔʾͼƬµÄµØ·½Ìí¼ÓÈçÏ´úÂë:
<asp:image id="imgPhoto" runat="server" ImageUrl="ShowPhoto.aspx"></asp:image>
ShowPhoto.aspxÖ÷Ìå´úÂ룺
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
SqlConnection conn=new SqlConnection()
conn.ConnectionString="Data Source=localhost;Database=test;User Id=sa;Pw
Ïà¹ØÎĵµ£º
SqlServerÃüÃû¹æ·¶
²Î¿¼¸÷ÖÖÃüÃû¹æ·¶£¬ÎÒÃÇͳһʹÓÃÃüÃû¹æ·¶ÈçÏ£º
ÃüÃû¹ý³ÌÖÐÈçÓÐÏÖ´æµÄËõд£¬ÔòʹÓøÃËõд£¬ÈçÎÞ£¬Ò»Âɲ»µÃËõд£¬Àý£ºISBN
Êý¾Ý¿â£ºÓÃÒ»¸ö»òÈý¸öÒÔÏÂÓ¢Îĵ¥´Ê×é³É£¬µ¥´ÊÊ××Öĸ´óд£¬È磺DepartmentManage£»
±íÃû£ºÊ¹ÓÃÃû´ÊÐÔÖʵĵ¥´Êȫƴ±íʾ£¬¸÷µ¥´ÊÊ××Öĸ´óд£¬ ʹÓø´ÊýÐÎʽ£¬È磺Books
& ......
²âÊÔµÄʱºò±È½ÏÖØÒª£¬ÎÒÃÇ¿ÉÒÔÖªµÀµ±Ç°½»Ò×Ó°ÏìÁËÄÄЩ±í
--ÓÃÓڼǼÓû§ÔÚµ±Ç°±íÉÏʲôʱºò¡¢×öµÄʲô²Ù×÷£ºupdate¡¢insert¡¢delete
create table TriggerRecord
(
operdt datetime, --´¥·¢Ê±¼ä
opertp varchar(10), --²Ù×÷ÀàÐÍ£ºupdate¡¢insert¡¢delete
opertb varchar(50) --±íÃû ......
ÔÚwindows 7 ÉÏΪ sqlserver 2008 ÆôÓÃÔ¶³Ì·ÃÎÊ£¬ÐèÒªÁ½¸öÖØµãµÄ²½Öè¡£
µÚÒ»²½£ºÆôÓÃsqlserver 2008Ô¶³Ì·ÃÎʵŦÄÜ¡£
´ò¿ªMicrosoft SQL Server 2008-ÅäÖù¤¾ß-SQL Server ÅäÖùÜÀíÆ÷
ÆôÓò¢¼¤»îTcp/IP
È»ºóÖØÆôsqlserver·þÎñ¡£ÕâÑùsqlserver 2008¾Í¿ÉÒÔ½øÐÐÔ¶³ÌÁ¬½ÓÁË¡£µ«ÊÇwin7 ·À»ðǽĬÈÏÊÇ×èÖ¹ÁËsqlsever ¿ª· ......
sqlserver µÄntextÀàÐÍÔÚÊý¾Ý¿âÖÐÊÇ¿´²»µ½ÖµµÄ
Æð³õÎÒ»¹ÒÔΪÊý¾ÝûÓвåÈ룬ºóÀ´²ÅÖªµÀntextÀàÐÍÔÚÊý¾Ý¿âÖб¾À´¾Í¿´²»µ½µÄ£¨Êý¾Ý½Ï¶ÌµÄ¿ÉÒÔ¿´µ½£©£»
ÄÇÎÒÒªÏë¿´µ½ntextÊý¾ÝÔõô°ì£¿
ÔÚ²éѯ·ÖÎöÆ÷ÖпÉÒÔ¿´µ½£¨²éѯ·ÖÎöÆ÷ÖÐÒ²Ö»¿´µ½ÁËǰ¼¸Ê®¸ö×Ö·û£¬¡¡²»ÊÇÈ«²¿µÄ£© ......
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlC ......