Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Where is invisible problem in the code here?

Where is invisible problem in the code here?

Scheduled Pinned Locked Moved Visual Basic
questioncsharpdatabasehelp
3 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JUNEYT
    wrote on last edited by
    #1

    Hello! This sample procedure extracts email addresses and adds to database. However, it is successfully adding the first address and creating empty records for the others. I decided to test the procedure with vb.net and took out adding the database section. It worked perfectly. So I would like to know what is causing not to add other emails except the first one. Thank You Sub AddEmails() Dim GetEmails Dim SrchKey Dim xPos Dim x1, x2 Dim xAddr GetEmails = Request.Form("emails") xPos = 1 x1=Instr(xpos,GetEmails,VbCrLf) DO WHILE xpos <= len(Getemails) x1=Instr(xPos,GetEmails,vbCrLf) x2=Instr(xPos+1 ,GetEmails,vbCrLf) If x1 = 0 or x2 = 0 Then Exit Do If xPos = 1 Then xAddr = Mid(GetEmails,1,x1-1) Elseif xpos > 1 Then xAddr = Mid(GetEmails, x1, x2 - x1) End If If len(xAddr) > 4 Then 'check here if email address is not exist in the database SrchKey = "SELECT * FROM emails WHERE email="& "'" & xAddr & "';" Call InitializeConnection() Call Establish_Recording(SrchKey) If ObjectRecord.RecordCount <= 0 Then ObjectRecord.Close ObjectConnection.Close Set ObjectRecord = Nothing Call InitializeConnection() Call InitializeRecordSet("Emails") 'PROBLEM IS CAUSED BY THE FOLLOWING STATEMENTS 'IT IS ADDING THE FIRST ADDRESS BUT NOT THE OTHERS ObjectRecord.AddNew ObjectRecord("email") = xAddr ObjectRecord("Accept") = True ObjectRecord.update ObjectRecord.Close ObjectConnection.Close Set ObjectRecord = Nothing

    G 1 Reply Last reply
    0
    • J JUNEYT

      Hello! This sample procedure extracts email addresses and adds to database. However, it is successfully adding the first address and creating empty records for the others. I decided to test the procedure with vb.net and took out adding the database section. It worked perfectly. So I would like to know what is causing not to add other emails except the first one. Thank You Sub AddEmails() Dim GetEmails Dim SrchKey Dim xPos Dim x1, x2 Dim xAddr GetEmails = Request.Form("emails") xPos = 1 x1=Instr(xpos,GetEmails,VbCrLf) DO WHILE xpos <= len(Getemails) x1=Instr(xPos,GetEmails,vbCrLf) x2=Instr(xPos+1 ,GetEmails,vbCrLf) If x1 = 0 or x2 = 0 Then Exit Do If xPos = 1 Then xAddr = Mid(GetEmails,1,x1-1) Elseif xpos > 1 Then xAddr = Mid(GetEmails, x1, x2 - x1) End If If len(xAddr) > 4 Then 'check here if email address is not exist in the database SrchKey = "SELECT * FROM emails WHERE email="& "'" & xAddr & "';" Call InitializeConnection() Call Establish_Recording(SrchKey) If ObjectRecord.RecordCount <= 0 Then ObjectRecord.Close ObjectConnection.Close Set ObjectRecord = Nothing Call InitializeConnection() Call InitializeRecordSet("Emails") 'PROBLEM IS CAUSED BY THE FOLLOWING STATEMENTS 'IT IS ADDING THE FIRST ADDRESS BUT NOT THE OTHERS ObjectRecord.AddNew ObjectRecord("email") = xAddr ObjectRecord("Accept") = True ObjectRecord.update ObjectRecord.Close ObjectConnection.Close Set ObjectRecord = Nothing

      G Offline
      G Offline
      Garner T
      wrote on last edited by
      #2

      This is just a guess. Wouldn't the ( xAddr="" ) set a blank each time the program made a loop?

      J 1 Reply Last reply
      0
      • G Garner T

        This is just a guess. Wouldn't the ( xAddr="" ) set a blank each time the program made a loop?

        J Offline
        J Offline
        JUNEYT
        wrote on last edited by
        #3

        Hello! Thanks for your respond. Xaddr returns a value eact time in the loop. I have tested the code with vb.net. I think having connection to database or recordset inseide the loop is causing the problem even though connection is getting closed and object record set to nothing.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups