123 Eng

Engineering the engineers™


Latest Jobs   Forum Map

 


Home

Source Codes

Engineering Colleges

BE Students

Training  Reports (updated)

Seminar Reports (updated

Placement Papers (updated)

Forums

   Computer Science / IT

   Electronics

   Electrical

   Mechanical

   Chemical

   Civil

   CAT / MBA

   GMAT / Foreign MBA

Latest Jobs

Engineering Jobs / Technical Jobs

Management Jobs

Sitemap

About-Us

Terms of use

Displaying  Source Code(s)  
 

 
Add New Record with ADO

--------------------------------------------------------------------------------

Description : This page demonstrates the capabilities how to add a record to a database using ADO instead of SQL. The script is:

<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>
<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
%>
 

 

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved © copyright 123ENG