We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

quoted string not properly terminated

mtnseeker
mtnseeker asked
on
Medium Priority
830 Views
Last Modified: 2012-05-11
Have an excel file I am importing into an Oracle database using a small C# application only problem is that if someone sticks an apostrophe in there it kills the entire process. I am doing an insert to a temp table and then using a package to do the final insert.  Suggestions?

below is where I am parsing through the excel. The issue happens with the comments column.
 
while ((line = sr.ReadLine()) != null)
                {
                    cnt2 += 1;
                    row = line.Split(',');
                    ExternalAcct = row[2];
                    FirstCompDate = row[3];
                    LastCompDate = row[4];
                    CompCode = TranCompCode(row[5]);
                    Comments = row[20].Replace("'","");

                    if (ExternalAcct != "" && is_date(FirstCompDate) && is_date(LastCompDate) && CompCode != "")
                    {
                        // set up Oracle reader ---------------------
                        cnt += 1;
                        OraCmd.CommandText = "Insert into CIRC.TH_STC_Temp Values ("
                                           + cnt.ToString()
                                           + ", 0"
                                           + ", '" + CompCode
                                           + "', to_date('" + FirstCompDate + "','YYYYMMDD')"
                                           + ", to_date('" + LastCompDate + "','YYYYMMDD')"
                                           + ",'" + ExternalAcct
                                           + "', '" + row[5] 
                                           + "', '" + row[20] + "')";
                        OraCmd.ExecuteScalar();
                    }

Open in new window

Comment
Watch Question

Information Services Manager
CERTIFIED EXPERT
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
Ron MalmsteadInformation Services Manager
CERTIFIED EXPERT

Commented:
example...

Comments = row[20].Replace("'","''");
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.