Replace by "

Hi,,,,
this is my code..

strAryWords = Split(readln, " ")
dId = strAryWords(0)
dName = strAryWords(1)
dPayout = strAryWords(2)
dType = strAryWords(3)
adoCon.Execute "Insert Into TABLE(ID, Name, Payout, Type) Values('"& dId &"','"& dName &"','"& dPayout &"','"& dType &"')"

now in my dName field I am getting name like : America's great toy...
Then it ll not allow to pass dName in table..
Its giving error :

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression ''America's great toy','33.50','lead')'.
/Data.asp, line 31

Now I am replacing

dName=Replace(dName,"'","") then its adding data to DB..
But I dont want to discard (') . I just want Data As it is ..
Is it Possible ??

Or Shall I replace (') by any other String ??
PLZ Solve this...
[1076 byte] By [tejalm] at [2007-11-19 19:53:30]
# 1 Re: Replace by "
A simple old trick...

1. Replace the apostrophe with "-apostrophe-" when writing to the database.
2. When querying back from the database replace "-apostrophe-" with the apostrophe.

Please start using code tags (http://www.dev-archive.com/forum/misc.php?do=bbcode). It makes posts easier to read.
PeejAvery at 2007-11-8 0:22:41 >
# 2 Re: Replace by "
Don't replace apostrophe with a null string rather replace it with double apostrophe and it will insert single apostrophe into the database.

Basically apostrophe is a special character when it comes to SQL Query so you need to take care of it like this dName=Replace(dName,"'","''")
Shuja Ali at 2007-11-8 0:23:46 >
# 3 Re: Replace by "
Thanks Sauja Ali... It's working...
Thanks a lot...
tejalm at 2007-11-8 0:24:42 >
# 4 Re: Replace by "
If it is for use in a webpage then you can also replace it with the ASCII value
http://www.w3schools.com/tags/ref_ascii.asp
degsy at 2007-11-8 0:25:45 >
# 5 Re: Replace by "
Hi..
Have another query...
I have CSV file and I have fields like ID, Name, Value..
In name field many times value s like::
"America's Greatest Offer, get FREE"...
So here comma coming and its separating and I am not getting proper data in table.
tejalm at 2007-11-8 0:26:44 >
# 6 Re: Replace by "
Well, there is no way around this with commas because that is how a CSV (comma separated values) file works. Make it separated by a semicolon and parse it with that.
PeejAvery at 2007-11-8 0:27:51 >
# 7 Re: Replace by "
When you export your CSV make sure you enclose strings in double quotes.
degsy at 2007-11-8 0:28:52 >
# 8 Re: Replace by "
Hi,
I have one CSV file and its field containing comma itself so when I am splitting by comma to get all data in ACCESS locally on my pc its giving error.
What to do for this ??
Code ::

<%
Dim adoCon
Dim rs
Dim strSQL
dim DNS
DSN = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.Mappath("MAP.mdb") & ";"
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open(DSN)
Set rs = Server.CreateObject("ADODB.Recordset")
adoCon.Execute "Delete * from Affiliate"

Dim filename, content
filename = "E:\\Affiliate.txt"
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set f=fs.OpenTextFile(filename, 1)

dim i,j,readln,lined,strAryWords
dim dId,dType,dName,dPayout
do while f.AtEndOfStream = false
readln=f.ReadLine
strAryWords = Split(readln, ",")
dId = strAryWords(0)
Response.Write("ID : "+dId+"<br>")
dName = strAryWords(1)
dName=Replace(dName,"'","''")
Response.Write(dName+"<br>")
dPayout = strAryWords(2)
Response.Write(dPayout+"<br>")
dType = strAryWords(3)
Response.Write(dType+"<br>")

adoCon.Execute "Insert Into Affiliate(ID, Name, Payout, Type) Values('"& dId &"','"& dName &"','"& dPayout &"','"& dType &"')"
loop
f.Close
Set f=Nothing
Set fs=Nothing
%>

Its giving error as

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression '' Master's',' or Doctorate degree at home!"')'.
/quick/MAP/Afl_data.asp, line 37

Bcoz line is like ::

"Kennedy Western - Earn your Bachelor's, Master's, or Doctorate degree at home!"
I have enclosed all data in before getting file..
So every field containing " at starting and ending.
Please solve this
Thanks
tejalm at 2007-11-8 0:29:44 >