Mac
02-09-2003, 10:29 AM
Here is my code:
<CODE>
rsAccCode.MoveFirst
Do until rsAccCode.EOF
if rsAccCode.Fields("AccessCodes").Value=x_AccCode then
' Open Connection to the database
set conn = Server.CreateObject("ADODB.Connection")
conn.Open xDb_Conn_Str
Set objRS = Server.CreateObject("ADODB.Recordset")
SQL= "SELECT Username,AccCode,EmailAddress FROM tblUsers"
Set objRS =conn.Execute (SQL)
strUsername = Request.Form("x_Username")
strAccCode = Request.Form("x_AccCode")
strEmail = Request.Form("x_EmailAddress")
Do While Not objRs.EOF
if objRS("Username")=strUsername Then
Response.redirect "exists.htm"
Elseif objRS("AccCode")= strAccCode then
Response.redirect "exists.htm"
Elseif objRS("EmailAddress")=strEmail then
Response.redirect "exists.htm"
End if
objRS.MoveNext
Loop
Select Case a
Case "A": ' Add
' Open record
strsql = "SELECT * FROM [tblUsers] WHERE 0 = 1"
set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strsql, conn, 1, 2
rs.AddNew
tmpFld = Trim(x_Username)
If trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Username") = tmpFld
tmpFld = Trim(x_AccCode)
If trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("AccCode") = tmpFld
tmpFld = Trim(x_FirstName)
If trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("FirstName") = tmpFld
tmpFld = Trim(x_Surname)
If trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Surname") = tmpFld
tmpFld = Trim(x_School)
If trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("School") = tmpFld
tmpFld = Trim(x_Grade)
If trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Grade") = tmpFld
tmpFld = Trim(x_EmailAddress)
If trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("EmailAddress") = tmpFld
tmpFld = Trim(x_AccessLevel)
If trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("AccessLevel") = tmpFld
tmpFld = x_Date
If IsDate(tmpFld) Then
rs("Date") = cDate(tmpFld)
Else
rs("Date") = Null
End If
tmpFld = x_ExpiryDate
If IsDate(tmpFld) Then
rs("ExpiryDate") = cDate(tmpFld)
Else
rs("ExpiryDate") = Null
End If
rs.Update
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing
Response.Clear
Response.Redirect "successreg.htm"
End Select
Response.End
end if
rsAccCode.MoveNext
loop
Response.redirect "exists.htm"
</CODE>
My problem is that the code wont run , because it goes directly to the 'Response.redirect "exists.htm"' , please can someone help me ive tried everything .
Thanks
<CODE>
rsAccCode.MoveFirst
Do until rsAccCode.EOF
if rsAccCode.Fields("AccessCodes").Value=x_AccCode then
' Open Connection to the database
set conn = Server.CreateObject("ADODB.Connection")
conn.Open xDb_Conn_Str
Set objRS = Server.CreateObject("ADODB.Recordset")
SQL= "SELECT Username,AccCode,EmailAddress FROM tblUsers"
Set objRS =conn.Execute (SQL)
strUsername = Request.Form("x_Username")
strAccCode = Request.Form("x_AccCode")
strEmail = Request.Form("x_EmailAddress")
Do While Not objRs.EOF
if objRS("Username")=strUsername Then
Response.redirect "exists.htm"
Elseif objRS("AccCode")= strAccCode then
Response.redirect "exists.htm"
Elseif objRS("EmailAddress")=strEmail then
Response.redirect "exists.htm"
End if
objRS.MoveNext
Loop
Select Case a
Case "A": ' Add
' Open record
strsql = "SELECT * FROM [tblUsers] WHERE 0 = 1"
set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strsql, conn, 1, 2
rs.AddNew
tmpFld = Trim(x_Username)
If trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Username") = tmpFld
tmpFld = Trim(x_AccCode)
If trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("AccCode") = tmpFld
tmpFld = Trim(x_FirstName)
If trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("FirstName") = tmpFld
tmpFld = Trim(x_Surname)
If trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Surname") = tmpFld
tmpFld = Trim(x_School)
If trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("School") = tmpFld
tmpFld = Trim(x_Grade)
If trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Grade") = tmpFld
tmpFld = Trim(x_EmailAddress)
If trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("EmailAddress") = tmpFld
tmpFld = Trim(x_AccessLevel)
If trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("AccessLevel") = tmpFld
tmpFld = x_Date
If IsDate(tmpFld) Then
rs("Date") = cDate(tmpFld)
Else
rs("Date") = Null
End If
tmpFld = x_ExpiryDate
If IsDate(tmpFld) Then
rs("ExpiryDate") = cDate(tmpFld)
Else
rs("ExpiryDate") = Null
End If
rs.Update
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing
Response.Clear
Response.Redirect "successreg.htm"
End Select
Response.End
end if
rsAccCode.MoveNext
loop
Response.redirect "exists.htm"
</CODE>
My problem is that the code wont run , because it goes directly to the 'Response.redirect "exists.htm"' , please can someone help me ive tried everything .
Thanks