SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: help with asp database ... again !!!!

  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2004
    Location
    Kentucky USA
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    help with asp database ... again !!!!

    I previously posted here with a problem i had with getting a check on my database variables... Now I am checking two variables... it works with one... what am i doing wrong when i try two ?????
    code as follows
    <%
    Const adOpenStatic = 3
    Const adLockOptimistic = 3
    Const adCmdTable = &H0002
    'our variables
    Dim strEmail, strName , objRS , objConn
    'get the results from the create newsletter form

    strEmail = Request.Form("emailadd")
    strName = Request.Form("name")
    Set objConn = Server.CreateObject("ADODB.Connection")
    objConn.Open "DBQ=" & Server.MapPath("newsletter.mdb")& ";Driver={Microsoft Access Driver (*.mdb)}"
    'create recordset object and open it
    Set objRS = Server.CreateObject("ADODB.RecordSet")
    objRS.Open "email" ,objConn,adOpenStatic,adLockOptimistic,adCmdTable
    'our bookmark
    strBookmark = objRS.Bookmark
    'loop through records trying to find our email
    While not objRS.EOF
    If (objRS("email") = strEmail And objRS("name") = strName ) Then
    strBookmark = objRS.Bookmark
    Else
    strBookmark = ""
    End If
    objRS.MoveNext

    Wend
    If strBookmark <> "" then
    objRS.Bookmark = strBookmark
    'delete entry
    objRS.delete
    'close recordset and connection
    Else
    Response.Redirect ("retry.html")
    %>
    seems that the problem is in the line.....

    If (objRS("email") = strEmail And objRS("name") = strName )

    when using
    If (objRS("email") = strEmail)
    it works fine ... but need to check both variables email and name

    Please help !!!!
    Look forward to your reply... anyone !!

  2. #2
    Original Gangster silver trophy SitePoint Award Recipient Thing's Avatar
    Join Date
    Oct 2000
    Location
    Jackson, NJ
    Posts
    4,708
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try adjusting your parentheses

    Code:
    IF (objRS("email") = strEmail) AND (objRS("name") = strName) THEN
    Are you receiving an error, or is it just not working properly?

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2004
    Location
    Kentucky USA
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear thing !!
    Thought you saw the last of me ????
    I tried before you suggested it to change the parentheses to your suggestion ... still the same problem
    it works fine with one item in the database..... when using more than one entry it seems to only look at the last entry for some reason when you try and delete something. entering the correct details for the last entry will bring success.
    Hope this sheds a little more light on this problem..... 3 hours later and here i still am !! Newbies ehhh ??

  4. #4
    SitePoint Enthusiast
    Join Date
    Dec 2004
    Location
    Kentucky USA
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    seems like there was some bad lines.... went back to your original posting from my early question.... got rid of the line that defined strBookmark before the search ..... used your original code for testing of the bookmark... and hey... presto..... it works !!!! at 1:30 am !!
    new code as follows if anyone is interested....

    <%
    Const adOpenStatic = 3
    Const adLockOptimistic = 3
    Const adCmdTable = &H0002
    'our variables
    Dim strEmail, strName , strBookmark , objRS , objConn
    'get the results from the create newsletter form

    strEmail = Request.Form("emailadd")
    strName = Request.Form("name")
    Set objConn = Server.CreateObject("ADODB.Connection")
    objConn.Open "DBQ=" & Server.MapPath("newsletter.mdb")& ";Driver={Microsoft Access Driver (*.mdb)}"
    'create recordset object and open it
    Set objRS = Server.CreateObject("ADODB.RecordSet")
    objRS.Open "email" ,objConn,adOpenStatic,adLockOptimistic,adCmdTable
    'our bookmark

    'loop through records trying to find our email
    While not objRS.EOF
    IF (objRS("name") = strName) AND (objRS("email") = strEmail) THEN
    strBookmark = objRS.Bookmark
    End If
    objRS.MoveNext

    Wend
    If strBookmark <> "" then
    objRS.Bookmark = strBookmark
    'delete entry
    objRS.delete
    'close recordset and connection
    Else
    Response.Redirect ("retry.html")
    End if
    objRS.Close
    objConn.Close
    'delete object variables
    Set objRS = Nothing
    Set objConn = Nothing
    %>
    Many thanks again....... its nice to bounce ideas around !!

  5. #5
    Original Gangster silver trophy SitePoint Award Recipient Thing's Avatar
    Join Date
    Oct 2000
    Location
    Jackson, NJ
    Posts
    4,708
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Way to stick with it!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •