Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


problem with problem chr in string when trying to save data to firebird db, how to fix

Posted on 2006-10-19
Medium Priority
Last Modified: 2010-04-23
im trying to read the files on a disk and some of the file names have a ' in it like c:\ero'sfiles.txt this is creating a problem for saving this to a firebird db (sql). how do i fix this a replace chr? or a excape chr maybe?

whats the code needed to fix this pleae too

thank you in advance for and code and help you my provide
Question by:Johnny
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 10

Expert Comment

ID: 17771200
normally you use '' instead of ' so the way to correct is:
insert into customers (fname,lname) values ('john','" & replace(lname,"'","''") & "')"

Author Comment

ID: 17771328
im reading files of a directory and theres a ' in the path/name of the file its saving to the database...
as a result the saved string its creating a problem for firebird db to understand and crashing at that point..i was thinking of doing a regex on the string but i dont knjow how to fix the problem if it needs to add a chr or replace it or what to fix the sql saved data string (modding it to work correctly)

            ' process all files in folder first
            Dim arrFiles() As String = System.IO.Directory.GetFiles(path)
            For Each eleFile As String In arrFiles
                Label1.Text = eleFile.ToString
                FileCount = FileCount + 1
                Label2.Text = FileCount.ToString
so i assume wed have to change the eleFile to be parsed with the ' chr this way correcting the problem, but as ive said im not sure if it needs to be replaced or added to excape the chr or what to fix the problem..imnot sure of the code on how to do that too.

Accepted Solution

Mohamed Zedan earned 2000 total points
ID: 17773833
all you have to do is insert this line here :

 For Each eleFile As String In arrFiles
                Label1.Text = eleFile.ToString
                dim NewFileName as string = elefile.Replace("'","""")  ' <--------------New Line
                InsertData(CreateFileInsertStatement(NewFileName)) '<------------Editted line
                FileCount = FileCount + 1
                Label2.Text = FileCount.ToString

Author Comment

ID: 17777884
Thank you

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question