Jump to content

paulonu

Members
  • Posts

    3
  • Joined

  • Last visited

paulonu's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. paulonu

    Update Record Set

    Redsun,I took out the extra code but it doesn't work yet. The error message I get is the regular:The page cannot be displayed There is a problem with the page you are trying to reach and it cannot be displayed. Thanks for your help.
  2. paulonu

    Update Record Set

    Hi Redsun,Thanks for your help. I used your suggestion but still get an error on the page. This is what my code looks like. Am I missing something?<%'Dimension variablesDim adoCon 'Holds the Database Connection ObjectDim rsAddComments 'Holds the recordset for the new record to be addedDim strSQL 'Holds the SQL query to query the databaseSet rsAddComments = Server.CreateObject ("ADODB.Command")rsAddComments.ActiveConnection = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("guestbook.mdb")rsAddComments.CommandText = "INSERT INTO tblComments (Name, Comments) VALUES ('" & Request.Form("name") & "', '" & Request.Form("comments") & "')"rsAddComments.CommandType = 1rsAddComments.CommandTimeout = 0rsAddComments.Prepared = truersAddComments.Execute()%> I also tried adding the RS.update line at the end. But that didn't work either. 'Write the updated recordset to the databasersAddComments.Update'Reset server objectsrsAddComments.CloseSet rsAddComments = NothingSet adoCon = Nothing'Redirect to the guestbook.asp pageResponse.Redirect "guestbook.asp"
  3. paulonu

    Update Record Set

    Hello,I'm taking my first few steps in the asp playground and I need a little help understading why my page is hanging on the record set update. Can anyone help me troubleshoot? I stepped thru the page line by line and the error comes up after: rsAddComments.UpdateBest,NewbieDev <%'Dimension variablesDim adoCon 'Holds the Database Connection ObjectDim rsAddComments 'Holds the recordset for the new record to be addedDim strSQL 'Holds the SQL query to query the database'Create an ADO connection objectSet adoCon = Server.CreateObject("ADODB.Connection")'Set an active connection to the Connection object using a DSN-less connectionadoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("guestbook.mdb")'Create an ADO recordset objectSet rsAddComments = Server.CreateObject("ADODB.Recordset")'Initialise the strSQL variable with an SQL statement to query the databasestrSQL = "SELECT tblComments.Name, tblComments.Comments FROM tblComments;"'Set the cursor type we are using so we can navigate through the recordsetrsAddComments.CursorType = 2'Set the lock type so that the record is locked by ADO when it is updatedrsAddComments.LockType = 3'Open the recordset with the SQL query rsAddComments.Open strSQL, adoCon'Tell the recordset we are adding a new record to itrsAddComments.AddNew'Add a new record to the recordsetrsAddComments.Fields("Name") = Request.Form("name")rsAddComments.Fields("Comments") = Request.Form("comments")'Write the updated recordset to the databasersAddComments.Update'Reset server objectsrsAddComments.CloseSet rsAddComments = NothingSet adoCon = Nothing'Redirect to the guestbook.asp pageResponse.Redirect "guestbook.asp"%>
×
×
  • Create New...