¹Ø±ÕÊý¾Ý¿âÁ¬½ÓµÄ¸ßЧ·½·¨ (asp.net 2.0 C#)
ÎÒÃÇ»¹¿ÉÒÔ²ÉÓÃÒ»ÖÖ¸ü¼Ó¼ò±ãµÄ·½
·¨À´ÊµÏÖÉÏÊö³ÌÐòµÄ¹¦ÄÜ¡£Õâ¾ÍÊǽ«SqlConnection¶ÔÏó°üº¬µ½usingÇø¿éÖУ¬ÕâÑù³ÌÐò»á×Ô¶¯µ÷ÓÃDispose()·½·¨ÊÍ·Å
SqlConnection¶ÔÏóËùÕ¼ÓõÄϵͳ×ÊÔ´£¬ÎÞÐèÔÙʹÓÃSqlConnection¶ÔÏóµÄClose()·½·¨¡£
·¶Àý³ÌÐò´úÂëÈçÏ£º
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string connectionString = "server=localhost;database=Northwind;
integrated security=SSPI";
SqlConnection mySqlConnection = new SqlConnection(connectionString);
using (mySqlConnection)
{
mySqlConnection.Open();
lblInfo.Text = "<b>mySqlConnection¶ÔÏóµÄConnectionStringÊôÐÔΪ£º<b>" +
mySqlConnection.ConnectionString + "<br>";
lblInfo.Text += "<b>mySqlConnection¶ÔÏóµÄConnectionTimeoutÊôÐÔΪ<b>" +
mySqlConnection.ConnectionTimeout + "<br>";
lblInfo.Text += "<b>mySqlConnection¶ÔÏóµÄDatabaseÊôÐÔΪ<b>" +
mySqlConnection.Database + "<br>";
lblInfo.Text += "<b>mySqlConnection¶ÔÏóµÄDataSourceÊôÐÔΪ<b>" +
mySqlConnection.DataSource + "<br>";
lblInfo.Text += "<b>mySqlConnection¶ÔÏóµÄPacketSizeÊôÐÔΪ<b>" +
mySqlConnection.PacketSize + "<br>";
lblInfo.Text += "<b>mySqlConnection¶ÔÏóµÄServerVersionÊôÐÔΪ<b>" +
Ïà¹ØÎĵµ£º
ÌõÐÎÂëÊÇÆù½ñΪֹ×á¢ÊµÓõÄÒ»ÖÖ×Ô¶¯Ê¶±ð¼¼Êõ¡£ÌõÐÎÂë¼¼Êõ¾ßÓÐÒÔϼ¸¸ö·½ÃæµÄÓŵã
¡¡¡¡A£®ÊäÈëËٶȿ죺Óë¼üÅÌÊäÈëÏà±È£¬ÌõÐÎÂëÊäÈëµÄËÙ¶ÈÊǼüÅÌÊäÈëµÄ5±¶£¬²¢ÇÒÄÜʵÏÖ“¼´Ê±Êý¾ÝÊäÈ딡£
¡¡¡¡B£®¿É¿¿ÐԸߣº¼üÅÌÊäÈëÊý¾Ý³ö´íÂÊΪÈý°Ù·ÖÖ®Ò»£¬ÀûÓùâѧ×Ö·ûʶ±ð¼¼Êõ³ö´íÂÊΪÍò·ÖÖ®Ò»£¬¶ø²ÉÓÃÌõÐÎÂë¼¼ÊõÎóÂëÂʵ ......
Ò»£ºC# Á¬½ÓSQLÊý¾Ý¿â
Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;
Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;
Server=myServerAddress;Database=myDataBase;User ID=myUse ......
ASP.NETÊý¾Ý¿âÁ¬½Ó×Ö·û´®µÄ¼ÓÃÜÓë½âÃÜ
ASP.NETÊý¾Ý¿âÁ¬½Ó×Ö·û´®µÄ¼ÓÃÜÓë½âÃÜ
ASP.NET web.configÖУ¬Êý¾Ý¿âÁ¬½Ó×Ö·û´®µÄ¼ÓÃÜÓë½âÃÜ¡£
¿ªÊ¼--->ÔËÐÐ,ÊäÈëcmd£¬½Ó×ÅÊäÈëÒÔÏÂÄÚÈÝ
¼ÓÃÜ£º
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -pef "connectionStrings" "ÄãµÄWebÏîĿ·¾¶"
¸´ÖÆ´úÂë ......
ASP.NetÖÐ×îΪͷʹµÄ¿ÉÄܾÍÊÇ´òÓ¡ÉèÖÃÁË¡£
ΪÁËÕâ¸öÎÊÌ⣬ÎÒ¶¼Òª°¾°×Í·ÁË¡£ÍøÉÏÒ²ÕÒÁ˺ܶà´úÂ룬µ«ÊÇ×ÜÊÇ»á´æÔÚһЩÎÊÌâ¡£¸ù¾ÝÎÒ×Ô¼ºµÄʵ¼ÊÊÔÑé·¢ÏÖ²»ÄÜÓã¬ÎªÕÒ²»µ½¶ÔÏóÖ®ÀàµÄ´íÎóÌáʾ¡£
ÕâÀï¸ø³öÁ½ÖÖʵ¼Ê¿ÉÓõķ½·¨£º
Ò»¡£Í¨¹ý×¢²á±íÐÞ¸ÄIE´òÓ¡ÉèÖÃ
<HTML>
<HEAD>
< ......