Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB
ÈÈÃűêÇ©£º c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 ×îÐÂÎÄÕ : sql

±¸·ÝºÍ»¹Ô­SQL Server¼°Ñ¹ËõAccessÊý¾Ý¿â

*
 * ¹¦ÄÜ˵Ã÷:±¸·ÝºÍ»Ö¸´SQL ServerÊý¾Ý¿â
 * ×÷Õß: Áõ¹¦Ñ«;
 * °æ±¾:V0.1(C#2.0);ʱ¼ä:2007-1-1
 * µ±Ê¹ÓÃSQL Serverʱ,ÇëÒýÓà COM×é¼þÖеÄ,SQLDMO.dll×é¼þ
 * µ±Ê¹ÓÃAccessÖÐ,Çëä¯ÀÀÌí¼ÓÒýÓÃÒÔÏÂÁ½¸ödll
 *          ÒýÓÃC:/Program Files/Common Files/System/ado/msadox.dll,¸ÃDLL°üº¬ADOXÃüÃû¿Õ¼ä
 *          ÒýÓÃC:/Program Files/Common Files/System/ado/msjro.dll,¸ÃDLL°üº¬JROÃüÃû¿Õ¼ä
 * *******************************************************************************/
using System;
using System.Data;
using System.Configuration;
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.IO;
using ADOX;//¸ÃÃüÃû¿Õ¼ä°üº¬´´½¨ACCESSµÄÀà(·½·¨)--½â¾ö·½°¸ ==> ÒýÓà ==> Ìí¼ÓÒýÓà ==> ÓÎÀÀÕÒµ½.dll
using JRO;//¸ÃÃüÃû¿Õ¼ä°üº¬Ñ¹ËõACCES ......

±¸·ÝºÍ»¹Ô­SQL Server¼°Ñ¹ËõAccessÊý¾Ý¿â

*
 * ¹¦ÄÜ˵Ã÷:±¸·ÝºÍ»Ö¸´SQL ServerÊý¾Ý¿â
 * ×÷Õß: Áõ¹¦Ñ«;
 * °æ±¾:V0.1(C#2.0);ʱ¼ä:2007-1-1
 * µ±Ê¹ÓÃSQL Serverʱ,ÇëÒýÓà COM×é¼þÖеÄ,SQLDMO.dll×é¼þ
 * µ±Ê¹ÓÃAccessÖÐ,Çëä¯ÀÀÌí¼ÓÒýÓÃÒÔÏÂÁ½¸ödll
 *          ÒýÓÃC:/Program Files/Common Files/System/ado/msadox.dll,¸ÃDLL°üº¬ADOXÃüÃû¿Õ¼ä
 *          ÒýÓÃC:/Program Files/Common Files/System/ado/msjro.dll,¸ÃDLL°üº¬JROÃüÃû¿Õ¼ä
 * *******************************************************************************/
using System;
using System.Data;
using System.Configuration;
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.IO;
using ADOX;//¸ÃÃüÃû¿Õ¼ä°üº¬´´½¨ACCESSµÄÀà(·½·¨)--½â¾ö·½°¸ ==> ÒýÓà ==> Ìí¼ÓÒýÓà ==> ÓÎÀÀÕÒµ½.dll
using JRO;//¸ÃÃüÃû¿Õ¼ä°üº¬Ñ¹ËõACCES ......

SQLÖÐisnullº¯ÊýµÄÓ÷¨

Óï·¨£º
   isnull(check_expression,replacement_expression)
²ÎÊýcheck_expressionÓëreplacement_expressionÀàÐÍÐèÏàͬ
·µ»ØÖµ£º
   Èôcheck_expressionΪnull£¬Ôò·µ»Øreplacement_expression
   Èôcheck_expression²»Îªnull£¬Ôò·µ»Øcheck_expression ......

sql³õ¼¶Óï·¨ ±Ê¼Ç×ܽá

num_field   number(12,2); 
±íʾnum_fieldÊÇÒ»¸öÕûÊý²¿·Ö×î¶à10λ¡¢Ð¡Êý²¿·Ö×î¶à2λµÄ±äÁ¿¡£ 
case.....when Ó÷¨£¨Óëdecode£¨£©×÷ÓúÜÏñ£©
select case zsxm_dm
         when '02' then
          'Ӫҵ˰'
          when '09' then
          'Ó¡»¨Ë°'
         else
          'ÎÞË°ÖÖ'
       end
  from t_dm_gy_zsxm;
decode()º¯ÊýʹÓü¼ÇÉ
decode(Ìõ¼þ,Öµ1,·­ÒëÖµ1,Öµ2,·­ÒëÖµ2,...Öµn,·­ÒëÖµn,ȱʡֵ)
¡¡¸Ãº¯ÊýµÄº¬ÒåÈçÏÂ:
¡¡¡¡IF    Ìõ¼þ=Öµ1    THEN
¡¡¡¡RETURN(·­ÒëÖµ1)
¡¡¡¡ELSIF Ìõ¼þ=Öµ2 THEN
¡¡¡¡RETURN(·­ÒëÖµ2)
¡¡¡¡......
¡¡¡¡ELSIF Ìõ¼þ=Öµn THEN
¡¡¡¡RETURN(·­ÒëÖµn)
¡¡¡¡ELSE
¡¡¡¡RETURN(ȱʡֵ)
¡¡¡¡END IF
sign()º¯Êý¸ù¾Ýij¸öÖµÊÇ0¡¢ÕýÊý»¹ÊǸºÊý£ ......

ÓÃIP·ÃÎÊSQL Server 2008

1¡¢¿ªÊ¼->³ÌÐò-->Microsoft SQL Server 2005>ÅäÖù¤¾ß->SQL Server Configuration Manager->SQL Server 2005 ÍøÂçÅäÖà ->“xxx£¨ÄúµÄÊý¾Ý¿â£©”µÄЭÒ飬ÈçÏÂͼ
½«“Named Pipes”ºÍ“TCP/IP”µÄ״̬µ÷³É“ÆôÓÔ£¬·½·¨ÊÇÔÚ“Named Pipes”ºÍ“TCP/IP”ÉÏÓÒ¼ü²é¿´ÆäÊôÐÔ£¬ÔÚÆä“ЭÒéÑ¡Ï”Öн«“ÒÑÆôÓÔµ÷³É“ÊÇ”¡£ÈçÏÂͼ
£¨TCP/IP ÊôÐÔÑ¡Ï£©
ÔÚ“TCP/IP ”ÊôÐÔÑ¡ÏµÄ“IP µØÖ·”Ñ¡Ï½øÐÐÈçÏÂͼÉèÖÃ
½«“IP1”Ä£¿éϵēIP”µØÖ·ÌîдΪÄú±¾»úµÄIPµØÖ·
½«“TCP ¶¯Ì¬¶Ë¿Ú”ÉèΪ¿Õ£¨Ä¬ÈÏΪ0£¬¸ÄΪ¿Õ£©
½«“TCP ¶Ë¿Ú”ÌîдΪ“1433”£¨Èç¹ûÄú·þÎñÆ÷ÉÏÓй²´æÊý¾Ý¿â£¬Ç븳¸øËûÃDz»Í¬µÄTCP¶Ë¿Ú£¬Ð´Á¬½Ó×Ö·û´®ÊÇΪÆä´øÉϸ÷×ԵĶ˿ںţ©
½«“»î¶¯”ÏîºÍ“ÒÑÆôÓÔÏîÉèΪ“ÊÇ”
µã»÷“È·¶¨”½«ÒÔÉÏÉèÖñ£´æ
ÍâΧӦÓÃÅäÖÃÆ÷ÔÚSQL Server 2008ÒѾ­ÕÒ²»µ½ÁË¡£Ô­À´ÊǺϲ¢µ½ÁËÒ»¸öËùνµÄ“·½Ã改¤¾ßÀïÃæÁË
ÔÚ·þÎñÆ÷½ÚµãÉÏ£¬µ ......

sqlȨÏÞ

sqlȨÏÞ:
´´½¨User:
insert into mysql.user(Host,User,Password)
values("localhost","cordev",password("xasoftorg"));
insert into
mysql.user(Host,User,Password)
values("localhost","corhotfix",password("xasoftorg"));
insert into
mysql.user(Host,User,Password)
values("localhost","corint",password("xasoftorg"));
¸³ÓèȨÏÞ£º
grant
all privileges on cordev.* to cordev identified by 'xasoftorg';
grant
all privileges on corhotfix.* to corhotfix identified by 'xasoftorg';
grant
all privileges on corint.* to corint identified by 'xasoftorg';
Ë¢ÐÂ:
flush
privileges;
Óû§È¨ÏÞ
ÉèÖÃ
¡¡¡¡1¡¢ÒÔroot£¨Ò²¿ÉÓÃÆäËüÓÐȨÏÞµÄÓû§£©Éí·ÝµÇ¼
¡¡¡¡2¡¢
ÏÂÃæ´´½¨Ò»¸ötestÓû§£¬ÃÜÂëΪtest£¬²¢ÇÒÖ»ÄܶÔpictureÊý¾Ý¿â½øÐвÙ×÷µÄÃüÁî
¡¡¡¡¡¡¡¡mysql>GRANT ALL ON
picture.* TO test IDENTIFIED BY "test";
¡¡¡¡GRANTÓï¾äµÄÓï·¨¿´ÉÏÈ¥ÏñÕâÑù£º
¡¡
¡¡GRANT privileges (columns) ON what TO user IDENTIFIE ......

C#Á¬½ÓACESSʱ£¬sqlÓï¾äÓдí

ÔÚдsqlÓï¾äʱ£¬Ò»°ã¶¼ÊÇÒ»¾ä½â¾ö£¬´ÓÀ´Ã»Ïë¹ý˵£¬°ÑsqlÓï¾ä²ð¿ªÀ´Ð´¡£
ÀýÈçÏÂÃæÕâ¾ä£º  string readstring = "select * from ʵÀý where ʵÀýID='"+eid+"'";
È»ºóÖ´ÐÐ Myconnection();
        DataSet ds = new DataSet();
        OleDbDataAdapter da = new OleDbDataAdapter(readstring, Mycon);
Õâʱºò¾Í»á±¨´í¡£¡£²»ÊÇ˵“sqlÓï¾äÓд픣¬¾ÍÊÇ“Êý¾ÝÀàÐͲ»Æ¥Å䔣¬¸üÂé·³µÄÊÇ£¬ÔËÐгɹ¦ÁË£¬µ«ÊÇÔËÐеĽá¹ûÒ»Ö±ÓÐ´í¡£¡£
ºóÀ´£¬²Å·¢ÏÖÔ­À´Èç¹ûÁ¬½ÓµÄÊÇacessµÄ»°£¬ÒÔÉϵÄÕâ¾äsqlÊÇÒª±ä³ÉÏÂÃæÕâÑùдµÄ£º
 string readstr = "select * from ʵÀý where ʵÀýID=";
 string readstring = readstr + eid;
ÏñÏÂÃæÕâÑùµÄ´úÂ룬²ÅÄÜÔËÐÐÎÞÎó£º
      int eid = Form1.int_selected + 1;
        string readstr = "select * from ʵÀý where ʵÀýID=";
        string readstring = readstr + eid;
        Myconn ......

C#Á¬½ÓACESSʱ£¬sqlÓï¾äÓдí

ÔÚдsqlÓï¾äʱ£¬Ò»°ã¶¼ÊÇÒ»¾ä½â¾ö£¬´ÓÀ´Ã»Ïë¹ý˵£¬°ÑsqlÓï¾ä²ð¿ªÀ´Ð´¡£
ÀýÈçÏÂÃæÕâ¾ä£º  string readstring = "select * from ʵÀý where ʵÀýID='"+eid+"'";
È»ºóÖ´ÐÐ Myconnection();
        DataSet ds = new DataSet();
        OleDbDataAdapter da = new OleDbDataAdapter(readstring, Mycon);
Õâʱºò¾Í»á±¨´í¡£¡£²»ÊÇ˵“sqlÓï¾äÓд픣¬¾ÍÊÇ“Êý¾ÝÀàÐͲ»Æ¥Å䔣¬¸üÂé·³µÄÊÇ£¬ÔËÐгɹ¦ÁË£¬µ«ÊÇÔËÐеĽá¹ûÒ»Ö±ÓÐ´í¡£¡£
ºóÀ´£¬²Å·¢ÏÖÔ­À´Èç¹ûÁ¬½ÓµÄÊÇacessµÄ»°£¬ÒÔÉϵÄÕâ¾äsqlÊÇÒª±ä³ÉÏÂÃæÕâÑùдµÄ£º
 string readstr = "select * from ʵÀý where ʵÀýID=";
 string readstring = readstr + eid;
ÏñÏÂÃæÕâÑùµÄ´úÂ룬²ÅÄÜÔËÐÐÎÞÎó£º
      int eid = Form1.int_selected + 1;
        string readstr = "select * from ʵÀý where ʵÀýID=";
        string readstring = readstr + eid;
        Myconn ......
×ܼǼÊý:4346; ×ÜÒ³Êý:725; ÿҳ6 Ìõ; Ê×Ò³ ÉÏÒ»Ò³[2] [3] [4] [5] [6] [7] [8] [9] [10]  ÏÂÒ»Ò³ βҳ
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ