asp.netÊý¾Ý¿â²Ù×÷Àà(´æ´¢¹ý³Ì´¦Àí)
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.ComponentModel;
namespace SQLHelper
{
/// <summary>
/// Class1 µÄժҪ˵Ã÷¡£
/// </summary>
public class SQLHelper
{
// Á¬½ÓÊý¾ÝÔ´
private SqlConnection myConnection;
private readonly string RETURNVALUE = "RETURNVALUE";
/// <summary>
/// ´ò¿ªÊý¾Ý¿âÁ¬½Ó.
/// </summary>
private void Open()
{
// ´ò¿ªÊý¾Ý¿âÁ¬½Ó
if (myConnection == null)
{
myConnection = new SqlConnection(ConfigurationSettings.AppSettings["SQLCONNECTIONSTRING"].ToString());
}
if(myConnection.State == ConnectionState.Closed)
{
try
{
///´ò¿ªÊý¾Ý¿âÁ¬½Ó
myConnection.Open();
}
catch(Exception ex)
{
SystemError.SystemLog(ex.Message);
}
finally
{
///¹Ø±ÕÒѾ´ò¿ªµÄÊý¾Ý¿âÁ¬½Ó
}
}
}
/// <summary>
/// ¹Ø±ÕÊý¾Ý¿âÁ¬½Ó
/// </summary>
public void Close()
{
///ÅжÏÁ¬½ÓÊÇ·ñÒѾ´´½¨
if(myConnection != null)
{
///ÅжÏÁ¬½ÓµÄ״̬ÊÇ·ñ´ò¿ª
if(myConnection.State == ConnectionState.Open)
{
myConnection.Close();
&
Ïà¹ØÎĵµ£º
ͨ³£javascript´úÂë¿ÉÒÔÓëHTML±êǩһÆðÖ±½Ó·ÅÔÚǰ¶ËÒ³ÃæÖУ¬µ«Èç¹ûJS´úÂë¶àµÄ»°Ò»·½Ãæ²»ÀûÓÚά»¤£¬ÁíÒ»·½ÃæÒ²¶ÔËÑË÷ÒýÇæ²»ÓѺã¬Òò
ÎªÒ³ÃæÒò´Ë¶ø±äµÃÓ·Ö×£»ËùÒÔÒ»°ãÓÐÁ¼ºÃ¿ª·¢Ï°¹ßµÄ³ÌÐòÔ±¶¼»á°Ñjavascript´úÂë·Åµ½¶ÀÁ¢µÄjsÎļþÖУ¬ÆäËûÒ³ÃæÍ¨¹ýÒýÈë¸ÃjsÎļþÀ´Ê¹ÓÃÏàÓ¦µÄ
javascript´úÂë¡£
½ñÌìÔÚ×öÒ»¸öСÐÂÎÅϵͳµÄ¹ÜÀí ......
//postÇëÇó
string name = Request["name"].toString();
string name =Request.Form.Get("name").toString();
//getÇëÇó
string name = Request.QueryString["name"].toString();
µ«ÎÒ·¢ÏÖ ÎÞÂÛÊÇ·ñÊÇpostÓëget´«Öµ
¶¼¿ÉÓÃstring name = Request["name"].toString();
±íµ¥Ìá½»ÖÐgetºÍpost·½Ê½µ ......
½ñÌ죬ѧϰÁËASP.NETÖÐÁ¬½ÓÊý¾Ý¿âµÄ¸÷ÖÖ·½·¨£¬ÕâÊÇÎÒ×Ô¼ºµÄÒ»¸öС×ܽᣬ²»Ò»¶¨ÍêÈ«ÕýÈ·£¬½ö¹©²Î¿¼£¡ O(∩_∩)O~
Á¬½ÓSQLÊý¾Ý¿âµÄ·½·¨£º
(Ò»)¡¢ÔÚWeb.ConfigÖд´½¨Á¬½Ó×Ö·û´®£º
1¡¢
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename= ......
Ò»£¬JS¶¯Ì¬´´½¨±íµ¥
var result = " <form method='post' action='../xiazai.aspx'><table width='100%' border='0' cellpadding='0' cellspacing='1' bgcolor='#BDB4A2'>"+
"&l ......
Ò»¡¢ASP.NET Web Service´úÂë
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Data.SqlClient;
namespace WebService1
{
/// <sum ......