Tuesday, January 20, 2009

 

ASP Add New Record with ADO



dbnewrec.asp

<% ' My ASP program that allows you to append a record %>

Author ID:


Author Name:


Year Born:






The form responder looks like this:

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






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 "VBScript Errors Occured!
"
Response.Write parm_msg & "

"
Response.Write pad & "Error Number= #" & Err.number & "
"
Response.Write pad & "Error Desc.= " & Err.description & "
"
Response.Write pad & "Help Context= " & Err.helpcontext & "
"
Response.Write pad & "Help File Path=" & Err.helpfile & "
"
Response.Write pad & "Error Source= " & Err.source & "

"
End Sub

Sub ErrorADOReport(parm_msg,parm_conn)
HowManyErrs=parm_conn.errors.count
If HowManyErrs=0 Then
Exit Sub
End If
pad=" "
Response.Write "ADO Reports these Database Error(s) executing:
"
Response.Write SQLstmt & "

"
For counter= 0 To HowManyErrs-1
errornum=parm_conn.errors(counter).number
errordesc=parm_conn.errors(counter).description
Response.Write pad & "Error#=" & errornum & "
"
Response.Write pad & "Error description="
Response.Write errordesc & "

"
Next
End Sub
%>


 
HTML clipboardWeb development continues to be a major focus in the latest release of Visual Studio. As with its predecessors, the 2008 release continues to evolve the .NET web development experience. The new tool is packed with additional design productivity enhancements, and there are new and improved controls, better IntelliSense, and support for LINQ—just to name a few features. These additions and improvements are meant to provide web developers more confidence and control when building their next web application with .NET. This chapter is focused on helping web developers leverage ASP.NET to create browser-based applications whose code runs on a server. These types of applications offer the broadest possible reach for web developers by targeting applications to work cross-browser and cross-platform with HTML-based compatibility. Of course, web development continues to evolve beyond the browser.

This page is powered by Blogger. Isn't yours?

Subscribe to Comments [Atom]