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

·ÀÖ¹SQL×¢Èë¹¥»÷µÄ×¢ÒâÊÂÏî

·ÀÖ¹SQL×¢Èë¹¥»÷µÄ×¢ÒâÊÂÏî
Ò». SQL Injection¼°Æä·À·¶µÄ»ù±¾ÖªÊ¶
¿ÉÄÜ´ó¼Ò¶¼ÖªµÀ£¬SQL×¢ÈëÖ÷ÒªÊÇÀûÓÃ×Ö·ûÐͲÎÊýÊäÈëµÄ¼ì²é©¶´¡£
±ÈÈç˵£¬³ÌÐòÖÐÓÐÕâÑùµÄ²éѯ£º
 string sql = "SELECT * from SiteUsers WHERE UserName='" + userName + "'";
ÆäÖеÄuserName²ÎÊýÊÇ´ÓÓû§½çÃæÉÏÊäÈëµÄ¡£
Èç¹ûÊÇÕý³£µÄÊäÈ룬±ÈÈç“Peter”£¬SQLÓï¾ä»á´®½Ó³É£º
 "SELECT * from SiteUsers WHERE UserName='Peter'";
Èç¹û¹¥»÷ÕßÊäÈëµÄÊÇÏÂÃæµÄ×Ö·û´®£º
  "xxx'; DROP TABLE SiteUsers WHERE 1=1 or UserName='xxx"
´ËʱSQLÓï¾ä»á±ä³ÉÏÂÃæÕâ¸öÑù×Ó£º
  "SELECT * from SiteUsers WHERE UserName='xxx'; DROP TABLE SiteUsers WHERE 1=1 or UserName='xxx'";
Æä½á¹û£¬µÃµ½Ö´ÐеÄÊÇÁ½¸öSQLÓï¾ä£¬µÚ¶þ¸öÓï¾äµÄºó¹û¾Í±È½ÏÑÏÖØÁË¡£
·ÀÖ¹×¢ÈëµÄ·½·¨ÆäʵºÜ¼òµ¥£¬Ö»Òª°ÑÓû§ÊäÈëµÄµ¥ÒýºÅ±ä³ÉË«·Ý¾ÍÐÐÁË£º
 string sql = "SELECT * from SiteUsers WHERE UserName='" + userName.Replace("'","''") + "'";
ÕâÑù£¬Èç¹ûÊäÈëµÄÊÇÉÏÃæÄÇÖÖ¶ñÒâ²ÎÊý£¬Õû¸öSQLÓï¾ä»á±ä³É£º
 "SELECT * from SiteUsers WHERE UserName='<STRONG>xxx''; DROP TABLE SiteUsers WHERE 1=1 or UserName=''xxx</STRONG>'";
±»Ö´ÐеĻ¹ÊÇÒ»¸öSQLÓï¾ä£¬Õû¸ö´ÖÌ岿·Ö¶¼³ÉΪ²ÎÊýÖµ¡£
Ò»°ãµÄ×ö·¨£¬ÊÇÔÚ³ÌÐòÖÐͳһµ÷ÓÃÏÂÃæÕâÑùµÄ¹²Í¨º¯Êý£¬¶Ô²ÎÊý½øÐд¦Àí£º
private string SafeSqlLiteral(string inputSQL)
{
&nbsp; return inputSQL.Replace("'", "''");
}
ÓÉÓںܶàÈË»áÊèºöÕâÖÖµ¥ÒýºÅÌæ»»£¬ËùÒÔÕæÕý°²È«µÄ×ö·¨ÊÇʹÓòÎÊý»¯²éѯ¡£
¶þ. ²ÎÊý»¯²éѯ
 ÔÚADO.NETÖУ¬ÌṩÁËÒ»ÖÖ²ÎÊý»¯²éѯ·½·¨£¬¿ÉÒÔÌæ´úÉÏÃæÕâÖÖÆ´½ÓSQLÓï¾äµÄ×ö·¨¡£
²ÎÊý»¯²éѯµÄ¾ßÌåʵÏÖÊÇ£º
£¨1£©×éÖ¯Ò»¸ö¼Ð´ø²ÎÊýÃûµÄSQLÓï¾ä£¬×÷ΪSqlCommandµÄCommandText¡£
£¨2£©Ê¹ÓÃParameters.Add·½·¨ÉèÖòÎÊýÖµ¡£
£¨3£©Ö´ÐÐSqlCommand¡££¨Õâ¸ö²½Öè¸úÉÏÃæÄÇÖÖÆ´½ÓSQLµÄ°ì·¨ÊÇÒ»ÑùµÄ¡££©
ÏÂÃæÊÇÒ»¸öÀý×Ó£º
  string sql = "SELECT T2.dep_code, T2.dep_name from DEP ";
 sql += " WHERE T2.dep_name like ('%'+ <STRONG>@Param</STRONG> + '%') ";
 SqlCommand sqlCommand = new SqlCommand(sql,cn);
 sqlCommand.Parameters.Add(new SqlParameter("Param",s);
ÆäÖеÄ@Param¾ÍÊDzÎÊýÃû£¬sÔòÊÇÓû§ÊäÈëµÄ²éѯÌõ¼þ×Ö´®¡£
£¨Ë³±


Ïà¹ØÎĵµ£º

c#Æô¶¯Sql Server·þÎñ

³ÌÐòÆô¶¯Sql ServerÆäʵºÜ¼òµ¥
´úÂ룺
System.ServiceProcess.ServiceController   myController   =
new   System.ServiceProcess.ServiceController("MSSQL$ACCP4444"); //·þÎñÃû³Æ ÕÒÁË°ëÌì²ÅÕÒµ½£¬±¿ËÀÎÒÍêÁË¡£ÔÚ·þÎñÉÏÓÒ¼üÊôÐÔ£¬ÄÜ¿´µ½
if (myController.CanStop)
{ }
else ......

°²×°SQL Sever 2008ʱ ´íÎó´úÂë: 1605 µÄ½â¾ö·½·¨


TITLE: SQL Server °²×°³ÌÐòʧ°Ü¡£
------------------------------
SQL Server °²×°³ÌÐòÓöµ½ÒÔÏ´íÎó:
MsiGetProductInfo ÎÞ·¨¼ìË÷ Product Code Ϊ“{95120000-00B9-0409-0000-0000000FF1CE}”µÄ°üµÄ ProductVersion¡£´íÎó´úÂë: 1605¡£¡£
Óöµ½Õâ¸ö´íÎóʱ£¬½â¾ö·½·¨ÈçÏ£º
µ±ÏµÍ³ÌáʾÈç {95120000-0 ......

ʹÓÃvisio 2003½¨Á¢sql server·´Ïò¹¤³Ì

Èý²½×ß¡£
<1>½¨Á¢Êý¾ÝÔ´
´ò¿ª¿ØÖÆÃæ°å—>¹ÜÀí¹¤¾ß—>Êý¾ÝÔ´ (ODBC)£¬»òÖ±½ÓÔËÐÐodbccp32.cplÃüÁî¡£´ò¿ªODBCÊý¾ÝÔ´¹ÜÀíÆ÷¡£Ìí¼ÓÒ»¸öϵͳÊý¾ÝÔ´¡£Ñ¡ÔñSql Server×÷ΪÊý¾ÝÔ´µÄÇý¶¯³ÌÐò£¬¼üÈëÊý¾ÝÔ´Ãû³Ædemo£¬Ñ¡ÔñºÏÊʵÄsql server·þÎñÆ÷£¬È»ºóһ·ĬÈÏÏÂÈ¥¡££¨ÔÚºóÃæµÄ²½ÖèÖпÉÒÔÑ¡ÔñÐèÒª½øÐз´Ïò¹¤³Ì ......

oracle Ïà關µÄsql語¾ä

Êý¾Ý×Öµädict×ÜÊÇÊôÓÚOracleÓû§sysµÄ¡£
¡¡¡¡1¡¢Óû§£º
¡¡¡¡¡¡select username from dba_users;
¡¡¡¡¸Ä¿ÚÁî
¡¡¡¡¡¡alter user spgroup identified by spgtest;
¡¡¡¡2¡¢±í¿Õ¼ä£º
¡¡¡¡¡¡select * from dba_data_files;
¡¡¡¡¡¡select * from dba_tablespaces;//±í¿Õ¼ä
¡¡¡¡¡¡select tablespace_name,sum(bytes), sum(b ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ