.NET³ÌÐò·À·¶SQL×¢Èëʽ¹¥»÷µÄ·½·¨
¡¡¡¡Ò»¡¢Ê²Ã´ÊÇSQL×¢Èëʽ¹¥»÷?
¡¡¡¡ËùνSQL×¢Èëʽ¹¥»÷£¬¾ÍÊǹ¥»÷Õß°ÑSQLÃüÁî²åÈëµ½Web±íµ¥µÄÊäÈëÓò»òÒ³ÃæÇëÇóµÄ²éѯ×Ö·û´®£¬ÆÛÆ·þÎñÆ÷Ö´ÐжñÒâµÄSQLÃüÁî¡£ÔÚijЩ±íµ¥ÖУ¬Óû§ÊäÈëµÄÄÚÈÝÖ±½ÓÓÃÀ´¹¹Ôì(»òÕßÓ°Ïì)¶¯Ì¬SQLÃüÁ»ò×÷Ϊ´æ´¢¹ý³ÌµÄÊäÈë²ÎÊý£¬ÕâÀà±íµ¥ÌرðÈÝÒ×Êܵ½SQL×¢Èëʽ¹¥»÷¡£³£¼ûµÄSQL×¢Èëʽ¹¥»÷¹ý³ÌÀàÈ磺
¡¡¡¡¢Å ij¸öASP.NET WebÓ¦ÓÃÓÐÒ»¸öµÇ¼ҳÃ棬Õâ¸öµÇ¼ҳÃæ¿ØÖÆ×ÅÓû§ÊÇ·ñÓÐȨ·ÃÎÊÓ¦Óã¬ËüÒªÇóÓû§ÊäÈëÒ»¸öÃû³ÆºÍÃÜÂë¡£
¡¡¡¡¢Æ µÇ¼ҳÃæÖÐÊäÈëµÄÄÚÈݽ«Ö±½ÓÓÃÀ´¹¹Ô춯̬µÄSQLÃüÁ»òÕßÖ±½ÓÓÃ×÷´æ´¢¹ý³ÌµÄ²ÎÊý¡£ÏÂÃæÊÇASP.NETÓ¦Óù¹Ôì²éѯµÄÒ»¸öÀý×Ó£º
¡¡¡¡System.Text.StringBuilder query = new System.Text.StringBuilder("SELECT * from Users WHERE login = ’")¡£Append(txtLogin.Text)¡£Append("’ AND password=’")¡£Append(txtPassword.Text)¡£Append("’");
¡¡¡¡¢Ç ¹¥»÷ÕßÔÚÓû§Ãû×ÖºÍÃÜÂëÊäÈë¿òÖÐÊäÈë"’»ò’1’=’1"Ö®ÀàµÄÄÚÈÝ¡£
¡¡¡¡¢È Óû§ÊäÈëµÄÄÚÈÝÌá½»¸ø·þÎñÆ÷Ö®ºó£¬·þÎñÆ÷ÔËÐÐÉÏÃæµÄASP.NET´úÂë¹¹Ôì³ö²éѯÓû§µÄSQLÃüÁµ«ÓÉÓÚ¹¥»÷ÕßÊäÈëµÄÄÚÈݷdz£ÌØÊ⣬ËùÒÔ×îºóµÃµ½µÄSQLÃüÁî±ä³É£ºSELECT * from Users WHERE login = ’’ or ’1’=’1’ AND password = ’’ or ’1’=’1’.
¡¡¡¡¢É ·þÎñÆ÷Ö´Ðвéѯ»ò´æ´¢¹ý³Ì£¬½«Óû§ÊäÈëµÄÉí·ÝÐÅÏ¢ºÍ·þÎñÆ÷Öб£´æµÄÉí·ÝÐÅÏ¢½øÐжԱȡ£
¡¡¡¡¢Ê ÓÉÓÚSQLÃüÁîʵ¼ÊÉÏÒѱ»×¢Èëʽ¹¥»÷Ð޸ģ¬ÒѾ²»ÄÜÕæÕýÑéÖ¤Óû§Éí·Ý£¬ËùÒÔϵͳ»á´íÎóµØÊÚȨ¸ø¹¥»÷Õß¡£
¡¡¡¡Èç¹û¹¥»÷ÕßÖªµÀÓ¦ÓûὫ±íµ¥ÖÐÊäÈëµÄÄÚÈÝÖ±½ÓÓÃÓÚÑéÖ¤Éí·ÝµÄ²éѯ£¬Ëû¾Í»á³¢ÊÔÊäÈëijЩÌØÊâµÄSQL×Ö·û´®´Û¸Ä²éѯ¸Ä±äÆäÔÀ´µÄ¹¦ÄÜ£¬ÆÛÆϵͳÊÚÓè·ÃÎÊȨÏÞ¡£
¡¡¡¡ÏµÍ³»·¾³²»Í¬£¬¹¥»÷Õß¿ÉÄÜÔì³ÉµÄËðº¦Ò²²»Í¬£¬ÕâÖ÷ÒªÓÉÓ¦Ó÷ÃÎÊÊý¾Ý¿âµÄ°²È«È¨ÏÞ¾ö¶¨¡£Èç¹ûÓû§µÄÕÊ»§¾ßÓйÜÀíÔ±»òÆäËû±È½Ï¸ß¼¶µÄȨÏÞ£¬¹¥»÷Õ߾ͿÉÄܶÔÊý¾Ý¿âµÄ±íÖ´Ðи÷ÖÖËûÏëÒª×öµÄ²Ù×÷£¬°üÀ¨Ìí¼Ó¡¢É¾³ý»ò¸üÐÂÊý¾Ý£¬ÉõÖÁ¿ÉÄÜÖ±½Óɾ³ý±í¡£
¡¡¡¡¶þ¡¢ÈçºÎ·À·¶?
¡¡¡¡ºÃÔÚÒª·ÀÖ¹ASP.NETÓ¦Óñ»SQL×¢Èëʽ¹¥»÷´³Èë²¢²»ÊÇÒ»¼þÌرðÀ§ÄѵÄÊÂÇ飬ֻҪÔÚÀûÓÃ±íµ¥ÊäÈëµÄÄÚÈݹ¹ÔìSQLÃüÁî֮ǰ£¬°ÑËùÓÐÊäÈëÄÚÈݹýÂËÒ»·¬¾Í¿ÉÒÔÁË¡£¹ýÂËÊäÈëÄÚÈÝ¿ÉÒÔ°´¶àÖÖ·½Ê½½øÐС£
¡¡¡¡¢Å ¶ÔÓÚ¶¯Ì¬¹¹ÔìSQL²éѯµÄ³¡ºÏ£¬¿ÉÒÔʹÓÃÏÂÃæµÄ¼¼Êõ£º
¡¡¡¡µÚÒ»£ºÌæ»»µ¥Òýº
Ïà¹ØÎĵµ£º
Update Channel set Unit ='mg' ,
RunUpThreshold='10' ,
RunDownThreshold='10' ,
SafetyUpThreshold='10' ,
SafetyDownThreshold='10'
where Bridge='001' and DeviceCode='AS'
and SensorCode='001' and Supplement='N'
set £º ','
where: and ......
PL/SQL-FOR UPDATE Óë FOR UPDATE OFµÄÇø±ð
url:http://hi.baidu.com/1413/blog/item/a521251f7e5993c4a686696b.html
Êý¾Ý¿â oracle for update of ºÍ for updateÇø±ð
select * from TTable1 for update Ëø¶¨±íµÄËùÓÐÐУ¬Ö»ÄܶÁ²»ÄÜд
2 select * from TTable1 wher ......
sql server 2000µ¼³ö±í½á¹¹
1.
SELECT
±íÃû=case when a.colorder=1 then d.name else '' end,
±í˵Ã÷=case when a.colorder=1 then isnull(f.value,'') else '' end,
×Ö¶ÎÐòºÅ=a.colorder,
×Ö¶ÎÃû=a.name,
±êʶ=case when COLUMNPROPERTY( a.id, ......
1. select top pageSize
* from table where id not in(select top((pageNo-1)*pageSize
) id from table order by id asc)
2. select * from table where id<=pageSize*pageNo
and id>(pageNo-1)*pageSize
order by id asc
×¢£º
pagesizeÿҳÏÔʾµÄ¼Ç¼Êý
pageNoµ±Ç°µÚ¼¸Ò³
......
ÎÒÃÇÖªµÀÓÃpowerdesignerµ¼³öµÄsqlÎļþºó׺Ϊ'.sql'£»ÓÃphpmyadminºÜÈÝÒ×µ¼ÈëMysQLÊý¾Ý¿â£¬µ«ÊÇÓÃPHPÔõôµ¼ÈëÊý¾Ý¿âÄØ?
ÎÒÓÃpowerdesignerÉè¼ÆÒ»¸öÊý¾Ý¿âºóµ¼³ösqlÎļþ£¨Ò»¸öͶƱϵͳ£©Îª'vote.sql'£»
ÎļþÄÚÈÝΪ£¨Ò»Ð©sqlÓï¾äºÍ×¢ÊÍ£©£º
/*======================= ......