83 lines
2.3 KiB
Plaintext
83 lines
2.3 KiB
Plaintext
|
<html><head>
|
||
|
<title>dbnewrec.asp</title></head>
|
||
|
<body bgcolor="#FFFFFF">
|
||
|
<% ' My ASP program that allows you to append a record %>
|
||
|
<form name="myauthor" action="dbnewADOrespond.asp" method="GET">
|
||
|
<p>Author ID: <Input Type="TEXT" name="id"></p>
|
||
|
<p> Author Name: <Input Type="TEXT" name="name"></p>
|
||
|
<p> Year Born: <Input Type="TEXT" name="year"></p>
|
||
|
<p> <Input Type="SUBMIT"> </p>
|
||
|
</form></body></html>
|
||
|
|
||
|
|
||
|
The form responder looks like this:
|
||
|
|
||
|
<TITLE>dbnewADO.asp</TITLE>
|
||
|
<body bgcolor="#FFFFFF">
|
||
|
<HTML>
|
||
|
<!--#INCLUDE VIRTUAL="/ADOVBS.INC" -->
|
||
|
<!--#INCLUDE VIRTUAL="/learn/test/lib_errors.asp" -->
|
||
|
<%
|
||
|
On Error Resume Next
|
||
|
auname=Request.QueryString("name")
|
||
|
auyear=Request.QueryString("year")
|
||
|
auID=Request.QueryString("ID")
|
||
|
If auid<9000 Then
|
||
|
auid=auid+9000
|
||
|
End If
|
||
|
conn="DSN=Student;uid=student;pwd=magic"
|
||
|
Set RS = Server.CreateObject("ADODB.Recordset")
|
||
|
RS.Open "authors",Conn,adopenstatic,adlockoptimistic
|
||
|
RS.AddNew
|
||
|
'RS("AU_ID")=auid
|
||
|
RS("Author") = auname
|
||
|
RS("Year_Born")= Int(auyear)
|
||
|
RS.Update
|
||
|
Call ErrorVBscriptReport("Adding Record")
|
||
|
Call ErrorADOReport("Adding Record",RS.activeconnection)
|
||
|
RS.Close
|
||
|
Set rs=Nothing
|
||
|
%>
|
||
|
</BODY>
|
||
|
</HTML>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
Here Is the include file that displays appropriate errors:
|
||
|
|
||
|
<%
|
||
|
Sub ErrorVBScriptReport(parm_msg)
|
||
|
If Err.number=0 Then
|
||
|
Exit Sub
|
||
|
End If
|
||
|
pad=" "
|
||
|
Response.Write "<b>VBScript Errors Occured!<br>"
|
||
|
Response.Write parm_msg & "</b><br>"
|
||
|
Response.Write pad & "Error Number= #<b>" & Err.number & "</b><br>"
|
||
|
Response.Write pad & "Error Desc.= <b>" & Err.description & "</b><br>"
|
||
|
Response.Write pad & "Help Context= <b>" & Err.helpcontext & "</b><br>"
|
||
|
Response.Write pad & "Help File Path=<b>" & Err.helpfile & "</b><br>"
|
||
|
Response.Write pad & "Error Source= <b>" & Err.source & "</b><br><hr>"
|
||
|
End Sub
|
||
|
|
||
|
Sub ErrorADOReport(parm_msg,parm_conn)
|
||
|
HowManyErrs=parm_conn.errors.count
|
||
|
If HowManyErrs=0 Then
|
||
|
Exit Sub
|
||
|
End If
|
||
|
pad=" "
|
||
|
Response.Write "<b>ADO Reports these Database Error(s) executing:<br>"
|
||
|
Response.Write SQLstmt & "</b><br>"
|
||
|
For counter= 0 To HowManyErrs-1
|
||
|
errornum=parm_conn.errors(counter).number
|
||
|
errordesc=parm_conn.errors(counter).description
|
||
|
Response.Write pad & "Error#=<b>" & errornum & "</b><br>"
|
||
|
Response.Write pad & "Error description=<b>"
|
||
|
Response.Write errordesc & "</b><p>"
|
||
|
Next
|
||
|
End Sub
|
||
|
%>
|