This is basically the same thing as what Tim said, but I figured I'd toss it in anyway.
Private Function DoubleQuote(fixText)
DoubleQuote = Replace(fixText,Chr(34),St
End Function
SQLString = "INSERT INTO dbo.CSF_Reports (CorpName, ReportType, ReportDate, FileNumber, OldCode) VALUES ('" & DoubleQuote(rsOldSource.Fi
Main Topics
Browse All Topics





by: TimCotteePosted on 2004-06-14 at 07:03:45ID: 11306480
Hi probelaw,
","''"),Ch r(34),Chr( 34)&Chr(34 ))
tem("Corpo ration_Nam e").Value) & "','" & FixUp(rsOldSource.Fields.I tem("Repor t_Type_ID" ).Value) & "','" & Fixup(rsOldSource.Fields.I tem("Repor t_Date").V alue) & "','" & FixUp(rsOldSource.Fields.I tem("File_ Number").V alue) & "'," & FixUp(rsOldSource.Fields.I tem("Repor t_ID").Val ue) & ")"
This is likely to cause a few issues as you will already have ' in the statement which you will be doubling and end up with something that will not work, much better to write a simple function:
Private Function FixUp(ByVal TheText As String) As String
FixUp = Replace(Replace(TheText,"'
End Function
Then use
SQLString = "INSERT INTO dbo.CSF_Reports (CorpName, ReportType, ReportDate, FileNumber, OldCode) VALUES ('" & FixUp(rsOldSource.Fields.I
Tim Cottee
Brainbench MVP for Visual Basic
http://www.brainbench.com