Imports System.IO
Imports Microsoft.Data
Imports System.Windows.Forms
Public Class Connection
    Dim str As String
    Public objDataset1 As New DataSet
    Public Function CreateDS(ByVal Str As String) As DataSet
        Try

            'Dim objDataset1 As DataSet
            'objDataset1 = Nothing

            Dim sConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\;Extended Properties=Text;"

            Dim objConn As New OleDb.OleDbConnection(sConnectionString)
            'Max(MarcRecID)
            objConn.Open()

            Dim objCmdSelect As New OleDb.OleDbCommand(Str, objConn)

            Dim objAdapter1 As New OleDb.OleDbDataAdapter

            objAdapter1.SelectCommand = objCmdSelect
            objAdapter1.Fill(objDataset1, "test")
            objConn.Close()

            Return objDataset1
        Catch ex As Exception
            'If ex.Message = "The Microsoft Jet database engine could not find the object 'Data.csv'.  Make sure the object exists and that you spell its name and the path name correctly." Then
            '    'MsgBox("File not Found")
            'End If
            ''MsgBox(ex.Message)
        End Try
    End Function
    Public Function RemoveComa(ByVal InString As String) As String

        Dim NlIndex As Integer
        Dim NlLastIndex As Integer
        Dim StrFinalRet As String
        Dim CharNewLine As Char
        CharNewLine = ","
        'here we will get the first newline character
        NlIndex = InString.IndexOf(CharNewLine)
        NlLastIndex = InString.LastIndexOf(CharNewLine)
        If NlIndex <> -1 And NlLastIndex <> -1 Then
            'in the loop remove the all newline character of record and after the loop we will get record in one line
            Do While (NlIndex <= NlLastIndex And NlIndex <> -1)
                'MsgBox(InString.IndexOf(Chr(13)))
                'If InString.IndexOf(Chr(13)) = -1 Then
                StrFinalRet = InString.Remove(NlIndex, 1)
                'Else
                '    StrFinalRet = InString.Remove(NlIndex - 1, 2)
                'End If
                InString = StrFinalRet
                NlLastIndex = InString.LastIndexOf(CharNewLine)
                NlIndex = InString.IndexOf(CharNewLine)
            Loop
            Return StrFinalRet
        Else
            StrFinalRet = InString
            Return StrFinalRet
        End If
    End Function
End Class
