在ASP中使用SQL語句,可以通過以下步驟:
Dim conn
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=SQLOLEDB; Data Source=myServerAddress; Initial Catalog=myDatabase; User ID=myUsername; Password=myPassword;"
Dim cmd
Set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = conn
cmd.CommandType = adCmdText
cmd.CommandText = "SELECT * FROM myTable"
Dim rs
Set rs = cmd.Execute
While Not rs.EOF
' 處理每一行數據
rs.MoveNext
Wend
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing
以上是一個簡單的使用SQL語句的示例,你可以根據具體的需求和數據庫類型進行相應的調整和擴展。