CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1

Threaded View

  1. #1
    Join Date
    May 2015
    Posts
    6

    Saving a recordset to CSV file, eliminate quotes question.

    I am working with an example which saves a recordset to a CSV file, but the resulting CSV file has quotes, all I need in commas.

    I can't seem to get the syntax correct for commas only.

    Code:
    Code:
    Public Function RecordsetToCSV(rsData As ADODB.Recordset, _
            Optional ShowColumnNames As Boolean = True, _
            Optional NULLStr As String = "") As String
    
        Dim K As Long, RetStr As String
        
        If ShowColumnNames Then
            For K = 0 To rsData.Fields.Count - 1
                RetStr = RetStr & ",""" & rsData.Fields(K).Name & """"
            Next K
            
            RetStr = Mid(RetStr, 2) & vbNewLine
        End If
        RetStr = RetStr & """" & rsData.GetString(adClipString, -1, """,""", """" & vbNewLine & """", NULLStr)
        RetStr = Left(RetStr, Len(RetStr) - 3)
        
        RecordsetToCSV = RetStr
    End Function

    Any advice appreciated.
    Last edited by Edward4; May 30th, 2015 at 06:40 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured