Tech Support Guy banner
Status
Not open for further replies.
1 - 1 of 1 Posts

·
Registered
Joined
·
2 Posts
Discussion Starter · #1 ·
trying to add to a database in asp but its not really working pls help

i have 2 files addrecord.html

Input New Record

Order Date

TotalOrder

</td.
[TD]

and addrecord.asp

<%
' read the data from the form and place in variables
varTotalOrder=request.form("TotalOrder")
varOrderDate=request.form("OrderDate")

'open database using standard connection
dim recsetado
dim dbpath
dbpath=Server.Mappath("PRPizza.mdb")
set db=server.createobject("adodb.connection")
set recsetado=server.createobject("adodb.recordset")
db.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & dbpath

'run SQL statement to check if name is already present

SQLQuerystring="SELECT OrderDate FROM ORDER WHERE OrderDate='" &varOrderDate& "';"
recsetado.open SQLQuerystring,db

'if EOF is reached without finding name

if recsetado.EOF then

'close previous recsetado statement

'recsetado.close

'run the UPDATE statement to add a new record
'NOTE there is no ID listed - this is set by by ACCESS autonumber when record is entered

SQLQuerystring="INSERT INTO ORDER(OrderDate,TotalOrder)Values('"&varOrderDate&"','"&varTotalOrder&"')"
recsetado.open SQLQuerystring,db

'Now print out the contents of the table to check it has been updated

recsetado.open "ORDER", db
recsetado.movefirst

'the field names will need changing for your database

response.write"
"
response.write"[TD]OrderDate[/TD]"
response.write"[TD]TotalOrder[/TD][/TR]"

'This writes a single row for each record and continues until there are no more records

do while not recsetado.eof
response.write"[TD]"&recsetado("OrderDate")&"[/TD]"
response.write"[TD]"&recsetado("TotalOrder")&"[/TD][/TR]"
recsetado.movenext
loop
response.write"
"
else

'if the name already exists the above code is ignored

response.write"OrderDate "&recsetado("OrderDate")&" already exists"
end if
%>

i keep getting page can not be displayed
 
1 - 1 of 1 Posts
Status
Not open for further replies.
Top