Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please help with the following ADO/DAO routines.

Status
Not open for further replies.

SkyHigh

Technical User
May 30, 2002
309
0
0
CA
Hi Folks

I am having a problem with the following ADO/DAO routines, if an address field contains double quotes (") it runs into errors, there are single quotes as well in the data I am dealing with, so is there another way with which it would be able to deal with double, single quotes and whatever.

Thank for your help
Brenda

---
Code:
---

sqlADORs = "SELECT id,name,address FROM remote_table"

Set ADORs = cPostgreSQL.Execute(sqlADORs, , adOpenForwardOnly) 'Fetching data from remote source

    If (Not ADORs.EOF And Not ADORs.BOF) Then 'Inserting into local access table
        Do Until ADORs.EOF
            db.Execute "INSERT INTO local_table (id, name, address " & _
                       "VALUES (""" & ADORs!ID & """,""" & ADORs!name & """,""" & ADORs!Address & " "")"
            ADORs.MoveNext
        Loop
    End If

---[Code]---
 
You can write a function. check for tick. then call this function on your fields.
 
chr(34) is double quotes and chr(39) is single quotes, sometimes it is easier to use these when concatenating variables.

"VALUES (" & chr(34) & ADORs!ID & chr (34) & "," & chr(34) & ADORs!name & chr (34) & "," & chr(34) & ADORs!Address & chr(34) & ")"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top