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

asp.net ÊÂÎñÀý×Ó

protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection conn;
SqlCommand cmd1, cmd2;
SqlTransaction tra;
conn = new SqlConnection("server=.;database=test;uid=sa;pwd=123");
conn.Open();
tra = conn.BeginTransaction();//¿ªÊ¼ÊÂÎñ
cmd1 = new SqlCommand("update Test set StuName='¼Ñ¶ù' where StuScore=111", conn);
cmd2 = new SqlCommand("update Test set StuName='fdsafdsafdsfdsafsfsdadsadsadfsafsfsfdf' where StuScore=222", conn);
try
{
cmd1.ExecuteNonQuery();//´Ë¾ä¿ÉÒԳɹ¦Ö´ÐÐ
cmd2.ExecuteNonQuery();//´Ë¾ä¹ÊÒâÈÃÆäÖ´ÐÐʧ°Ü
tra.Commit();//ÎÞÒì³££¬Ìá½»ÊÂÎñ(Á½¾äÖ´Ðж¼ÓÐЧ)
Response.Write("<mce:script type="text/javascript"><!--
alert('Ö´Ðгɹ¦')
// --></mce:script>");
}
catch
{
tra.Rollback();//³öÏÖÒì³££¬»Ø¹öÊÂÎñ(Á½¾äÖ´Ðж¼ÎÞЧ)
Response.Write("<mce:script type="text/javascript"><!--
alert('Ö´ÐÐʧ°Ü')
// --></mce:script>");
}
finally
{
conn.Close();
}
} 0 0 0
(ÇëÄú¶ÔÎÄÕÂ×ö³öÆÀ¼Û)


Ïà¹ØÎĵµ£º

asp.net´°ÌåµÄ´ò¿ªºÍ¹Ø±Õ

asp.net´°ÌåµÄ´ò¿ªºÍ¹Ø±Õ
//´ò¿ªÐµĴ°Ìå
Response.Redirect("WebMain.aspx");   
//µ¯³öÒ»¸öд°Ìå
Response.Write("<script>window.open(\"WebMain.aspx\")</script>")
//µ¯³öÒ»¸öÖ»ÓÐÈ·¶¨°´Å¥µÄÌáʾ¿ò
Response.Write("<script>alert(\"Óû§Ãû»òÃÜÂë´íÎó\");</script>") ......

ASP.NET(C#)ÖÐstringÓëstringBuilderµÄÇø±ð

 
ÔÚÏàͬ×Ö·û´®µÄÐí¶à²Ù×÷ÉÏ£¬Ê¹ÓÃStringBuilderÀà»á±ÈʹÓÃString¶ÔÏó¸üÓÐЧÂÊ¡£
 
 
 µ±Äã¶ÔÒ»¸östring¶ÔÏó¸³ÖµÊ±£¬Õâʱ»áÉú³ÉÒ»¸öÕâ¸ö¶ÔÏóµÄ¸±±¾£¬Èç¹ûÄ㸳ֵ¶à´ÎµÄ»°ÔÚϵͳÖоͻᱣ´æ¶à¸öÕâ¸ö¶ÔÏóµÄ¸±±¾£¬»á¶Ôϵͳ×ÊÔ´Ôì³ÉºÜ´óµÄÀË·Ñ£¬µ«ÊÇStringBuilder²»»á³öÏÈÉÏÊöÇé¿ö
StringÊý¾ÝÀàÐÍ´ú±íµÄ ......

asp.netÖг£ÓõÄÓÅ»¯ÐÔÄܵķ½·¨

1. Êý¾Ý¿â·ÃÎÊÐÔÄÜÓÅ»¯¡¡
¡¡
Êý¾Ý¿âµÄÁ¬½ÓºÍ¹Ø±Õ
·ÃÎÊÊý¾Ý¿â×ÊÔ´ÐèÒª´´½¨Á¬½Ó¡¢´ò¿ªÁ¬½ÓºÍ¹Ø±ÕÁ¬½Ó¼¸¸ö²Ù×÷¡£ÕâЩ¹ý³ÌÐèÒª¶à´ÎÓëÊý¾Ý¿â½»»»ÐÅÏ¢ÒÔͨ¹ýÉí·ÝÑéÖ¤£¬±È½ÏºÄ·Ñ·þÎñÆ÷×ÊÔ´¡£ASP.NETÖÐÌṩÁËÁ¬½Ó³Ø(Connection Pool)¸ÄÉÆ´ò¿ªºÍ¹Ø±ÕÊý¾Ý¿â¶ÔÐÔÄܵÄÓ°Ï졣ϵͳ½«Óû§µÄÊý¾Ý¿âÁ¬½Ó·ÅÔÚÁ¬½Ó³ØÖУ¬ÐèҪʱȡ³ö£¬¹Ø±ÕÊ±Ê ......

asp.netÉú³É¾²Ì¬Ò³Ãæ

Default..aspx
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
Default..aspx.cs
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.We ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ