Friday, December 14, 2007

How to detect the error while using the ADO?

How to detect the error while using the ADO?


We can detect the error while using the ADO.


The ASP codes are written and described as below:



<%

Set conn = Server.CreateObject("Adodb.Connection")

conn.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("db1.mdb")

Set rs = Server.CreateObject("Adodb.Recordset")

rs.open "Member",conn,1,3

rs.AddNew

rs.Fields("TheNameIsNotInTheDatabase")="Alvin" 'We use a field name that not used in the database

rs.Fields("Location")="UK"

If Err.Count > 0 Then

Response.write("Cannot Add new record")

Else

rs.Update

End If

rs.Close

Set rs = Nothing

%>

No comments: