not adding to database

not adding to database

am 24.04.2006 16:21:35 von Varun Jain

hi,
i was creating an asp page that is supposed to add some registration data to
a database. however, it is not adding to the database nor is it giving any
errors. this is really wierd. although, it is reading from the database.

i have attached the code for three files below
Register.asp
AddUser.asp
V2E2Connection.asp

Register.asp:
---------------------------







<%Session("blnValidUser")=True%>
Registration page




Register to V2E2



Username:


Password:


Verify Password: Name="strVerifyPassword">



First Name:


Family Name:



Age:


Gender:


Course:











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


AddUser.asp
----------------------------------

<%
Dim rsUsers
Set rsUsers = Server.CreateObject("ADODB.RecordSet")
rsUsers.Open "tblPerson", objConn, adOpenForwardOnly,
adLockBatchOptimistic, adCmdTable

If Session("strUserName") <> "" Then
rsUsers.Filter = "strUserName = '" & Request.Form("strUserName") & "'" & _
"AND strPassword = '" & Request.Form("strPassword") & "'"
If rsUsers.EOF Then
rsUsers.AddNew 'Else username/password match
End If
End If

'Add Record data...
rsUsers("strUserName") = Request.Form("strUserName")
rsUsers("strPassword") = Request.Form("strPassword")
rsUsers("strFirstName") = Request.Form("strFirstName")
rsUsers("strFamilyName") = Request.Form("strFamilyName")
rsUsers("strGender") = Request.Form("strGender")
rsUsers("intAge") = Request.Form("intAge")
rsUsers("strCourse") = Request.Form("strCourse")

rsUsers.Update

Dim strName, strValue 'populate the session variables to correspond to
data in database
For each strField in rsUsers.Fields
strName = strField.Name
strValue = strField.Value
Session(strName) = strValue
Next

Session("blnValidUser") = True 'login the user automatically
Response.Redirect "RegisteredIndex.asp" 'redirect to registered users
homepage
%>
---------------------------------


V2E2Connection.asp
---------------------------------

<%
'The following code is to be used as a SSI. It has all the data access
connection information.
'It declares a value to hold the database connection and then opens it.
'It also retrieves the current users PersonID from the database, so that it
can be used throughout the session

'Initialising the connection object
Dim objConn
Set objConn = Server.CreateObject("ADODB.Connection")
objCOnn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source= c:\datastores\v2e2.mdb"

'Checking if user is valid and if the PersonID parameter is set.
'If valid user and no personId, then creates a recordset object to get the
personID from the database

If Session("blnVaildUser") = True Then

Dim rsUserNameCheck
Set rsUserNameCheck = Server.CreateObject("ADODB.RecordSet")
Dim strSQL
strSQL = "SELECT * FROM tblPerson " & _
"WHERE strUserName = '" & Session("strUserName") & "';"
rsUserNameCheck.Open strSQL, objConn


If rsUserNameCheck.EOF Then 'If username is not present in the table
then, invalidate the user and log him out"
Session("blnValidUser") = False
End If
rsUserNameCheck.Close
Set rsUserNameCheck = Nothing
End If
%>
-------------------------------------------

Re: not adding to database

am 29.04.2006 15:49:06 von Emil Cristen

Varun Jain schreef:
> hi,
> i was creating an asp page that is supposed to add some registration data to
> a database. however, it is not adding to the database nor is it giving any
> errors. this is really wierd. although, it is reading from the database.
>
> i have attached the code for three files below
> Register.asp
> AddUser.asp
> V2E2Connection.asp
>
> Register.asp:
> ---------------------------
>
>
>
>
>
>
>
> <%Session("blnValidUser")=True%>
> Registration page
>
>
>
>
>

Register to V2E2


>
>

Username:


>

Password:


>

Verify Password: > Name="strVerifyPassword">



>

First Name:


>

Family Name:



>

Age:


>

Gender:


>

Course:


>
>

>
>

>
>
>
> -----------------------------------
>
>
> AddUser.asp
> ----------------------------------
>
> <%
> Dim rsUsers
> Set rsUsers = Server.CreateObject("ADODB.RecordSet")
> rsUsers.Open "tblPerson", objConn, adOpenForwardOnly,
> adLockBatchOptimistic, adCmdTable
>
> If Session("strUserName") <> "" Then
> rsUsers.Filter = "strUserName = '" & Request.Form("strUserName") & "'" & _
> "AND strPassword = '" & Request.Form("strPassword") & "'"
> If rsUsers.EOF Then
> rsUsers.AddNew 'Else username/password match
> End If
> End If
>
> 'Add Record data...
> rsUsers("strUserName") = Request.Form("strUserName")
> rsUsers("strPassword") = Request.Form("strPassword")
> rsUsers("strFirstName") = Request.Form("strFirstName")
> rsUsers("strFamilyName") = Request.Form("strFamilyName")
> rsUsers("strGender") = Request.Form("strGender")
> rsUsers("intAge") = Request.Form("intAge")
> rsUsers("strCourse") = Request.Form("strCourse")
>
> rsUsers.Update
>
> Dim strName, strValue 'populate the session variables to correspond to
> data in database
> For each strField in rsUsers.Fields
> strName = strField.Name
> strValue = strField.Value
> Session(strName) = strValue
> Next
>
> Session("blnValidUser") = True 'login the user automatically
> Response.Redirect "RegisteredIndex.asp" 'redirect to registered users
> homepage
> %>
> ---------------------------------
>
>
> V2E2Connection.asp
> ---------------------------------
>
> <%
> 'The following code is to be used as a SSI. It has all the data access
> connection information.
> 'It declares a value to hold the database connection and then opens it.
> 'It also retrieves the current users PersonID from the database, so that it
> can be used throughout the session
>
> 'Initialising the connection object
> Dim objConn
> Set objConn = Server.CreateObject("ADODB.Connection")
> objCOnn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
> "Data Source= c:\datastores\v2e2.mdb"
>
> 'Checking if user is valid and if the PersonID parameter is set.
> 'If valid user and no personId, then creates a recordset object to get the
> personID from the database
>
> If Session("blnVaildUser") = True Then
>
> Dim rsUserNameCheck
> Set rsUserNameCheck = Server.CreateObject("ADODB.RecordSet")
> Dim strSQL
> strSQL = "SELECT * FROM tblPerson " & _
> "WHERE strUserName = '" & Session("strUserName") & "';"
> rsUserNameCheck.Open strSQL, objConn
>
>
> If rsUserNameCheck.EOF Then 'If username is not present in the table
> then, invalidate the user and log him out"
> Session("blnValidUser") = False
> End If
> rsUserNameCheck.Close
> Set rsUserNameCheck = Nothing
> End If
> %>
> -------------------------------------------
>
>
HI,

Do you have write permission for the directory the database is stored.
Reminder; write permission should be set for the webserver user.