Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

add record to database in asp page using sql 1

Status
Not open for further replies.

ziggy72

Programmer
Nov 26, 2003
2
GB
i am trying to add a record to an asp page, i cannot find a good example of this on the net. i would prefer to use insert into rather than addrecord (or whatever it is called)
i am a newbie so if possible give it to me in simple terms. also any info on how to get the data from a text input to transfer into the db would be good

cheers

here is my existing code

<html>
<head>
<title>View Resources</title>
</head>
<body>

<%

'--Connect to the Resources.mdb database
set conn1=server.createobject("ADODB.connection")
conn1.Open "DBQ=" & Server.MapPath("resources.mdb") & ";Driver={Microsoft Access Driver (*.mdb)}"
'--Open the resources table - -
set rs1=server.createobject("ADODB.Recordset")
rs1.open "SELECT * FROM RsrcTb1" , conn1

'--show the resources on the form
rs1.movefirst
'--List the resources in an html table - -
'--Create the table heading - -
x="<table border=10 cellpadding=4><tr><th>Identifier</th><th>Title</th><th>Date</th></tr>"
response.write x
while not rs1.eof
x="<tr><td>" & rs1("Identifier") & "<td>" & rs1("Title") & "<td>" & rs1("Date") & "</tr>"
response.write x
rs1.movenext
wend
response.write"</table>"

'--SELECT Identifier FROM RsrcTb1

rs1.close
conn1.close
set rs1=nothing

sql = "INSERT INTO RsrcTb1 (Identifier, Title, Date) Values (11, 'bob', '4/3/2004')"

%>

</body>
</html>
 
set conn1=server.createobject("ADODB.connection")
conn1.Open "DBQ=" & Server.MapPath("resources.mdb") & ";Driver={Microsoft Access Driver (*.mdb)}"

sql = "INSERT INTO RsrcTb1 (Identifier, Title, Date) Values (11, 'bob', '4/3/2004')"


conn1.execute(sql)

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

zen.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top