Asp.NetÖÐsql server 2000/2005 Á¬½Ó×Ö·û´®
http://zhanglei1286.blog.163.com/blog/static/1895797120091112113019600/
ÔÚºǫ́´úÂëÀ
SQL 2000:
static string StrConn = "server=.;uid=sa;pwd=sa;database=MyCUDS";
SQL2005:
con = new SqlConnection(@"Server=.\SQLExpress;Database=db_CMS;Persist Security Info=True;User ID=sa;Password=Masslong");
ÔÚweb.configÀ
sql 2000:
<connectionStrings>
<add name="RateSystemConnectionString" connectionString="Data Source=.;Initial atalog=RateSystem;
User ID=sa Pwd=sa" providerName="System.Data.SqlClient" />
</connectionStrings>
sql 2005:
<connectionStrings>
<add name="BookShopConnectionString" connectionString="Data Source=.\SQLEXPRESS;
Initial Catalog=BookShop;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
/////////////////////////////////////////////
<connectionStrings>
<add name="ConnectionString" providerName="System.Data.SqlClient" connectionString="Data Source=(local);Initial Catalog=dbname;User ID=sa;Password=1"/>
</connectionStrings>
DBHelper.cs»ñµÃ×Ö·û´®
string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
(*×¢£ºData Source¿ÉÒÔÓÃServer´úÌ棬Initial Catalog±íʾÊý¾Ý¿âÃû£¬¿ÉÒÔÓÃDatabase´úÌ棬(local)±íʾ±¾µØÁ¬½Ó£¬Èç¹ûÊÇÔ¶³ÌÁ¬½Ó£¬¿ÉÒÔÓÃÔ¶³ÌÖ÷»úÃû»òIPÀ´±íʾ)
<appSettings>
<add key="ConnectionString" value="Data Source=(local);Initial Catalog=dbname;User ID=sa;Password=1"/>
</appSettings>
<appSettings>
<add key="ConnectionString" value="server=192.168.1.1;database=shop;uid=sa;pwd=*"/>
</appSettings>
DBHelper.cs»ñµÃ×Ö·û´®
string connectionString =ConfigurationManager.AppSettings["ConnectionString"];
Ïà¹ØÎĵµ£º
ÔÀ´ÓÃjQueryµÄajax·½Ê½µ÷ÓÃasp.netÒ³Ãæ»ù±¾¶¼Êǵ÷Óõ¥¸öÒ³Ã棬Óɵ÷ÓÃÒ³ÃæResponseÄÚÈÝ£¬¶øÏÖÔÚ²ÉÓÃasp.net ajaxºó£¬ÎÒÃÇÔò¿ÉÒÔ¸üÍêÃÀµÄʹÓÃjQueryºÍasp.net½áºÏÁË£¬´úÂëÈçÏ£º
<asp:ScriptManager ID="ScriptManager1" runat="server" >
<Scripts>
<asp:ScriptReference Path="http ......
ÅÅÃûº¯ÊýÊÇSQL Server2005мӵŦÄÜ¡£ÔÚSQL Server2005ÖÐÓÐÈçÏÂËĸöÅÅÃûº¯Êý£º
¡¡¡¡1.row_number
¡¡¡¡2.rank
¡¡¡¡3.dense_rank
¡¡¡¡4.ntile¡¡¡¡
¡¡¡¡ÏÂÃæ·Ö±ð½éÉÜÒ»ÏÂÕâËĸöÅÅÃûº¯ÊýµÄ¹¦Äܼ°Ó÷¨¡£ÔÚ½éÉÜ֮ǰ¼ÙÉèÓÐÒ»¸öt_table±í£¬±í½á¹¹Óë±íÖеÄÊý¾ÝÈçͼ1Ëùʾ£º
¡¡¡¡Í¼1
¡¡¡¡ÆäÖÐfield1×ֶεÄÀàÐÍÊÇint£¬field2×Ö¶ ......
¹ØÓÚClientIDµÄʹÓÃÎÒÓöµ½Ò»ÏÂÎÊÌ⣺
»ñÈ¡ÓÉ ASP.NET Éú³ÉµÄ·þÎñÆ÷¿Ø¼þ±êʶ·û¡£
ÎÊÌâÒ»£º Óû§¿Ø¼þµÄÒ³ÃæJavaScriptÖÐÐèҪʹÓÃAsp.netµÄ¿Ø¼þID£¬³öÏÖ²»Ò»Ö¡£
ÎÊÌâ¶þ£ºÄ¸°æÒ³µÄ×ÓÒ³ÃæJavaScriptÖÐÐèҪʹÓÃAsp.netµÄ¿Ø¼þID£¬³öÏÖ²»Ò»Ö¡£
½â¾ö°ì·¨£º
document.getElementById("<% ......