insert data to DB with MS SQL using Classic ASP

Ye Htut

Ye Htut

May 5 2014 1:09 AM
first I made "connection.asp"
the codes in "connection.asp" file are as follows

Dim conn
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=SQLOLEDB; Data Source = (local); Initial Catalog = Test; User Id = sa; Password=as"
If conn.errors.count = 0 Then
Response.Write "Connected OK"
End If

then I made "author.asp". The following code are in "author.asp"

<!DOCTYPE html>
<!--#include file="connection.asp" -->
<form method="post" action="author.asp">
<input type="text" name="aid"><br>
<label>Author Name</label>
<input type="text" name="aname"><br>
<input type="submit" value="Register">

dim aid,aname,objs
Set objdb=conn()
query = "INSERT INTO author (aid,aname) VALUES ('"& aid &"','"& aname &"')"
Set objs = objdb.Execute(query)
Response.Redirect ("thankyou.asp")

the code can't run. I think, there may be error in "author.asp". So, Plz help me

Answers (1)