<%@ Language=VBScript %>
淇濆瓨鏁撮〉璁板綍
<% ' 杩炴帴鏁版嵁搴撳苟鍒涘缓璁板綍闆嗗璞
Dim conn, rs
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\path\to\your\database.mdb"
Set rs = Server.CreateObject("ADODB.Recordset")
' 鑾峰彇琛ㄥ崟鎻愪氦鐨勬墍鏈夊瓧娈靛
For Each field In Request.Form
If Not IsEmpty(Request.Form(field)) Then
' 鏋勯 SQL INSERT 璇彞
sql = "INSERT INTO your_table (column1, column2) VALUES ('" & Replace(Request.Form(field), "'", "''") & "')"
' 鎵ц SQL 鏌ヨ
conn.Execute sql
End If
Next
' 鍏抽棴杩炴帴鍜岃褰曢泦瀵硅薄
rs.Close
conn.Close
Set rs = Nothing
Set conn = Nothing
%>

宸叉垚鍔熶繚瀛樻暣椤佃褰曪紒

涓婇潰鐨勪唬鐮佷細鏍规嵁琛ㄥ崟鎻愪氦鐨勬瘡涓瓧娈靛肩敓鎴愮浉搴旂殑 SQL INSERT



鏂规硶浜岋細


<%@ Language=VBScript %>
<% Option Explicit %>
 
' 瀹氫箟鏁版嵁搴撹繛鎺ュ瓧绗︿覆
Dim connStr
connStr = "Provider=SQLOLEDB;Data Source=(local);Initial Catalog=YourDatabaseName;User ID=YourUsername;Password=YourPassword;"
 
' 鍒涘缓 Connection 瀵硅薄
Set conn = CreateObject("ADODB.Connection")
conn.Open connStr ' 鎵撳紑鏁版嵁搴撹繛鎺
 
' 鏋勯 SQL INSERT 璇彞
Dim sqlInsert
sqlInsert = "INSERT INTO YourTable (Column1, Column2) VALUES ('Value1', 'Value2');" & _
            "INSERT INTO YourTable (Column1, Column2) VALUES ('Value3', 'Value4');" & _
            "INSERT INTO YourTable (Column1, Column2) VALUES ('Value5', 'Value6');"
 
' 鎵ц SQL INSERT 璇彞
conn.Execute(sqlInsert)
 
' 鍏抽棴鏁版嵁搴撹繛鎺
conn.Close()
Set conn = Nothing
%>




浠ヤ笂灏辨槸ASP淇濆瓨鏁撮〉澶氭潯璁板綍鐨勮缁嗗唴瀹癸紝鏇村淇℃伅璇峰叧娉∣D浜戝叾瀹冪浉鍏虫枃绔狅紒



鏈枃URL锛http://www.odweb.cn/news_show.html?id=237