Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ʹÓÃc#´´½¨sql serverµÄ´æ´¢¹ý³Ì_c#Ó¦ÓÃ1

½éÉÜ
ͨ³££¬Ñз¢ÈËԱʹÓõÄÊÇT-SQLÀ´´´½¨SQL ServerµÄ´æ´¢¹ý³Ì¡¢º¯ÊýºÍ´¥·¢Æ÷¡£ ¶øÏÖÔÚµÄSQL Server 2005ÒÑÍêÈ«Ö§³Ö.NETͨÓÃÓïÑÔÔËÐÐʱ£¨CLR£©ÁË¡£ Õâ¾ÍÒâζ×Å£¬ÄúÄܹ»Ê¹ÓÃ.NETµÄÓïÑÔ£¬ÈçC#¡¢VB.NETÖ®ÀàµÄÀ´Ñз¢SQL ServerµÄ´æ´¢¹ý³Ì¡¢º¯ÊýºÍ´¥·¢Æ÷¡£ SQL Server ºÍ CLR µÄ¼¯³É¸øÎÒÃÇ´øÀ´ÁËn¶àºÃ´¦£¬Èçʵʱ±àÒë¡¢ÀàÐÍ°²È«¡¢ÔöÇ¿µÄ°²È«ÐÔÁ¬Í¬ÔöÇ¿µÄ±à³ÌÄ£Ð͵ȡ£ ±¾ÎÄÖУ¬ÎÒ½«Ïò´ó¼ÒÑÝʾÈçºÎʹÓÃC#´´½¨SQL ServerµÄ´æ´¢¹ý³Ì¡£ .
±³¾°
ÎÒÃÇÔÚʹÓÃSQL Server´æ´¢¹ý³Ìʱ£¬×î³£×öµÄ¹¤×÷¾ÍÊÇ´ÓÊý¾Ý¿âÖжÁÈ¡»ò±£´æÊý¾Ý¡£ Æä³£ÓÃÓ¦ÓÃÈçÏ£º
·Ö´ÐÐһЩ¼òµ¥µÄÂß¼­£¬Ã»ÓÐÈκηµ»ØÖµ¡£ ҲûÓÐÊä³ö²ÎÊý¡£
·Ö´ÐÐһЩÂß¼­£¬²¢Í¨¹ýÒ»¸ö»ò¸ü¶àµÄÊä³ö²ÎÊý·µ»Ø½á¹û¡£
·Ö´ÐÐһЩÂß¼­£¬²¢·µ»Ø´Ó±íÖжÁÈ¡µÄÒ»Ìõ»ò¶àÌõ¼Ç¼¡£
·Ö´ÐÐһЩÂß¼­£¬²¢·µ»ØÒ»Ðлò¶àÐмǼ¡£ ÕâЩ¼Ç¼²»ÊÇ´Ó±íÖжÁÈ¡µÄ£¬¶øÊÇÄú×Ô¶¨ÒåµÄһЩÊý¾ÝÐС£ ¸ù¾Ýר¼Ò¹Û²ì£¬ÕâÑùµÄÀíÂÛºÍÏÖÏó¶¼ÊÇÖµµÃ¸÷λվ³¤Éî˼µÄ£¬ËùÒÔÏ£Íû´ó¼Ò¶à×öÑо¿Ñ§Ï°£¬ÕùÈ¡×ܽá³ö¸ü¶à¸üºÃµÄ¾­Ñé!
ΪÁËÑÝʾÈçºÎÓÃC#Ñз¢³öÕ⼸ÖÖÓ¦ÓõÄSQL Server´æ´¢¹ý³Ì£¬ÎÒ½«Ò»¸öÒ»¸öµØ¾Ù³öʾÀý¡£ .
ÆôÓÃCLR¼¯³É
ÔÚÄú¿ªÊ¼ÓÃC#д´æ´¢¹ý³Ì֮ǰ£¬±ØÐëÒªÆôÓÃÄúµÄSQL ServerµÄCLR¼¯³ÉÌØÐÔ¡£ ĬÈÏÇé¿öËûÊDz»ÆôÓõġ£ ´ò¿ªÄúµÄSQL Server Management Studio²¢Ö´ÐÐÈçϽű¾¡£
sp_configure clr enabled, 1
GO
RECONFIGURE
GO
ÕâÀÎÒÃÇÖ´ÐÐÁËϵͳ´æ´¢¹ý³Ì“sp_configure”£¬ÎªÆäÌṩµÄÁ½¸ö²ÎÊý·Ö±ðΪ£º“clr enabled”ºÍ“1”¡£¼ÙÈçҪͣÓÃCLR¼¯³ÉµÄ»°Ò²ÊÇÖ´ÐÐÕâ¸ö´æ´¢¹ý³Ì£¬Ö»µ«Êǵڶþ¸ö²ÎÊýÒª±äΪ“0”¶øÒÑ¡£ÁíÍ⣬ΪÁËʹеÄÅäÖòúÉúЧ¹û£¬²»ÒªÍü¼Çµ÷ÓÓRECONFIGURE”¡£ ¡£
SQL Server씀ÏÖÔÚ´ò¿ªVisual Studio£¬²¢´ÓÎĵµ²Ëµ¥ÖÐÑ¡Ôñ“н¨ÏîÄ¿”¡£ Ôړн¨ÏîÄ¿”¶Ô»°¿òÖÐÑ¡Ôñ“Visual C#”ϵēDatabase”¡£ È»ºóÑ¡Ôñ“SQL ServerÏîÄ¿”Ä£°å¡£ .¡¡
ÆðºÃÏîÄ¿Ãû³Æºó¾Íµ¥»÷“È·¶¨”°´Å¥¡£ .
ºÜ¿ì£¬ÄúËù´´½¨µÄÏîÄ¿¾ÍÐèÒªÄúÑ¡ÔñÒ»¸öSQL ServerÊý¾Ý¿â¡£ ³É¹¦µÄÈËÉú£¬ÐèÒª×Ô¼ºÈ¥¾­Óª£¬±ðÔÙ˵ÁË£¬ÄªÔÙµÈÁË£¬ÏÖÔÚ¾ÍΪ×Ô¼ºµÄÈËÉú×öºÃ¹æ»®£¬ÎªÈËÉúµãÁÁÒ»ÕµÃ÷µÆ£¬Ó®ÔÚÈËÉúÆðÅܵãÉÏ¡£
°´ÕÕÌáʾһ²½Ò»²½µØ×ö¾ÍºÃÁË£¬¾ÍËãÄúÑ¡ÔñÁËÈ¡Ïû£¬Ò²Äܹ»ÔÚ“ÏîÄ¿”–“ÊôÐÔ”¶Ô»


Ïà¹ØÎĵµ£º

Asp.Net C#ÖÐSession ÈçºÎ´¢´æÈ¡ÐÅÏ¢

ÒòΪ¸Õ¸Õ½Ó´¥C#ÓïÑÔ²»¾Ã,ÓÚÊÇÎÒ°Ñ¿ØÖÆ̨¸øÈÓÁË,ÒòΪÎÒÌÖÑá¿ØÖÆ̨!
¶øÊÂʵÉÏÎÒÖ»¶ÔWinForm¼¼Êõ¸ÐÐËȤ,µ«ÊÂʵÉϵ½ÏÖÔÚÎÒ·¢ÏÖASP.Net C#µÄWeb¼¼ÊõÊÇÈÕÏÔÖØÒªÆðÀ´!
ÓÚÊÇ¿ªÊ¼½Ó´¥,¸Õ¸ÕÆð²½ÓÚËùÖª,ÓÈÆäÊÇһЩ×î¼òµ¥µÄ¶«Î÷,µ½ÍøÉÏËÑË÷Á˺ܾÃ,²»ÊÇÌ«ÂÒ¾ÍÊÇ˵²»Çå³þ!
¾Ù¸öÀý×ÓÀ´Ëµ,¾Í˵SessionºÃÁË,²»ÖªµÀÍøÉϵÄÄÇЩ¼Ò»ïµ½µ×ÔÚ½²Ê ......

³£ÓÃSQL²éѯÓï¾ä

DDL—Êý¾Ý¶¨ÒåÓïÑÔ(CREATE£¬ALTER£¬DROP£¬DECLARE)
¡¡¡¡DML—Êý¾Ý²Ù×ÝÓïÑÔ(SELECT£¬DELETE£¬UPDATE£¬INSERT)
¡¡¡¡DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
¡¡¡¡Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
¡¡¡¡1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
CREATE DATABASE database-name
¡¡¡¡2¡¢ËµÃ÷£ºÉ¾³ýÊý¾Ý¿â
drop database ......

SQL´óÈ«

Ò»¡¢»ù´¡
1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
CREATE DATABASE database-name
2¡¢ËµÃ÷£ºÉ¾³ýÊý¾Ý¿â
drop database dbname
3¡¢ËµÃ÷£º±¸·Ýsql server
--- ´´½¨ ±¸·ÝÊý¾ÝµÄ device
USE master
EXEC sp_addumpdevice 'disk', 'testBack', 'c:\mssql7backup\MyNwind_1.dat'
--- ¿ªÊ¼ ±¸·Ý
BACKUP DATABASE pubs TO testBack
4¡¢Ëµ ......

c# SQLÊý¾Ý¿âÔ¶³ÌÁ¬½Ó¼°ÅäÖ÷½·¨

c# SQLÊý¾Ý¿âÔ¶³ÌÁ¬½Ó¼°ÅäÖ÷½·¨
Ò»£ºC# Á¬½ÓSQLÊý¾Ý¿â
Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;
Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;
Server=myServerAddress;D ......

c# SQLÊý¾Ý¿âÔ¶³ÌÁ¬½Ó¼°ÅäÖ÷½·¨

Ê×ÏÈÅäÖÃSQLSERVER2005£º
´ò¿ª”Microsoft SQL Server Management Studio“ Ö±½ÓÓÃWindows Óû§Á¬½Ó½øÈ룬ÔÙÔÚ“°²È«ÐÔ”ÖеēµÇ¼Ãû”Äڵēн¨µÇ¼Ãû”£¬Äã¾Í¶ÔÓ¦µÄÌíºÃ“È·¶¨”¾Í¿ÉÒÔÁË¡£  
ÔÙÔÚÄã¶ÔÓ¦µÄ“Êý¾Ý¿â”Àï“°²È«ÐÔ” ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ