|
Subject:
|
Win2003 and ASP adovbs.inc
|
|
Posted By:
|
danhur
|
Post Date:
|
12/16/2003 11:30:06 AM
|
I have a database that I have been using for 2 years that has worked perfectly using two include files in the beginning of my ASP pages. <!--#include file="connection.asp"--> <!--#include file="adovbs.inc"--> My ISP Host has updated his servers to Win2003 and now the insert new into the database for the registration section no longer inserts new data.
THe logic works, ie, if a new user puts in a user name that exists in the database on the server I get the appropriate error message.
code snippit:
DateMember = Now duplicate=false
'Create our recordset object Set objRS = Server.CreateObject("ADODB.Recordset")
'Open our recordset and our connection objRS.Open "NewMems", objConn , 2, 2 ' NewMems is table in Access DB objConn set up in include file.
'Run a test to make sure no duplicate username already exists 'This test works Do While Not (objRS.EOF OR duplicate) If (StrComp(objRS("username"), username, vbTextCompare) = 0) Then 'If a duplicate is found, we redirect back to the application.asp page with the correct error message response.redirect "membership_application.asp?error=2" End If 'Move to the next record and test it for a duplicate objRS.MoveNext 'Continue to loop through the recordset for duplicates Loop
'Assuming no duplicates were found, now we add a new record by calling the AddNew method objRS.AddNew ' Somewhere in here it errors cause data never enters as new record. 'Now we insert the values of our variables into the appropriate fields objRS.Fields("username") = username objRS.Fields("FirstName") = firstname objRS.Fields("LastName") = lastname objRS.Fields("Email") = email objRS.Fields("MembershipType") = membershiptype objRS.Fields("Browser") = Browser objRS.Fields("WhereFrom") = WhereFrom objRS.Fields("DateMember") = DateMember objRS.Fields("ExpirationDate") = frmExpireDates
'Finally, we call the update method to finish creating this record. Without calling the 'update method, it will not add the record so don't forget it.
objRS.Update If err.number>0 then response.write "VBScript Errors Occured:" & "<P>" response.write "Error Number=" & err.number & "<P>" response.write "Error Descr.=" & err.description & "<P>" response.write "Help Context=" & err.helpcontext & "<P>" response.write "Help Path=" & err.helppath & "<P>" response.write "Native Error=" & err.nativeerror & "<P>" response.write "Source=" & err.source & "<P>" response.write "SQLState=" & err.sqlstate & "<P>" end if bookmark = objRS.absolutePosition ' First, store the location of you cursor objRS.Requery ' Next, update your recordset with the data from the database objRS.movelast 'after the requery, the absolutePosition is the first record of the recordset 'objRS.absolutePosition = bookmark Finally, change your cursor back lUserID = objRS("memID") if lUserID >1 then Session("sesmemID") = lUserID end if
'Now we clean things up by closing our connection and recordset and setting both equal to nothing objRS.Close Set objRS = nothing objConn.Close Set objConn = nothing ' REDIRECT USER TO PAGE REQUESTED '''''''''''''''''''''''''''''''''' Response.Redirect "school_information.asp" 'works, inotherwords redirects to correct page %>
|
|
Reply By:
|
danhur
|
Reply Date:
|
12/16/2003 8:25:56 PM
|
Problem Solved, Called Host and had him verify the DSN and path and permissions and everything mysteriously started working again. Thanks all.
|
|