Connection to SQL Server from classic ASP (ok)
<%
Dim title, content
Dim connection, recordset, Baglanti
Baglanti = "Driver={SQL Server};Server={LIONEL};Database={TutorialDB};uid={test};pwd={lionel123}"
Set connection = Server.CreateObject("ADODB.Connection")
connection.Open Baglanti
title = 1
content = 2
Set recordset = connection.Execute("INSERT INTO student (name,roll) VALUES (1,1)")
connection.Close()
%>
Create new Data Source


Get Server Name


Create Login New




Create a New Data Source To SQL Server





insert into database to sql server




Đây là mã code
<%
Dim title, content
Dim connection, recordset, Baglanti
Baglanti = "Driver={SQL Server};Server={LIONEL};Database={TutorialDB};uid={test};pwd={lionel123}"
Set connection = Server.CreateObject("ADODB.Connection")
connection.Open Baglanti
title = 1
content = 2
Set recordset = connection.Execute("INSERT INTO student (name,roll) VALUES (1,1)")
connection.Close()
' Set recordset = connection.Execute("INSERT INTO tb_posts (title,content,status,deleted) VALUES ('"& title &"','"& content &"','"& status &"','N');")
%>
Chú ý: Sử dụng kiểu mẫu kết nối sau
Set recordset = connection.Execute("INSERT INTO tb_posts (title,content,status,deleted) VALUES ('"& title &"','"& content &"','"& status &"','N');")
Last updated
Was this helpful?