>> Dim LoDataTable As New DataTable >> Dim StrConnectionString as String = Utilities.GetConnString("c:\data", Utilities.ConnectionTypes.OLEDB_VFP_FreeTable) >> Dim StrQuery as String = "Select * from Paidinvs" >> Dim LoConn As New OleDb.OleDbConnection >> Dim loDataAdapter As New OleDb.OleDbDataAdapter >> >> Try >> LoConn.ConnectionString = StrConnectionString >> LoConn.Open() >> >> loDataAdapter = New OleDb.OleDbDataAdapter(StrQuery, LoConn) >> >> loDataAdapter.Fill(LoDataTable) >> Catch ex As Exception >> LoDataTable.Dispose() >> Throw ex >> Finally >> loDataAdapter.Dispose() >> LoConn.Close() >> End Try >> >>Public Class Utilities >> Enum ConnectionTypes >> OLEDB_VFP_FreeTable >> OLEDB_VFP_DBC >> OLEDB_Access >> OLEDB_Excel >> SQL_Standard >> SQL_Trusted >> End Enum >> >> Public Shared Function GetConnString(ByVal DataSource As String, ByVal ConnectType As ConnectionTypes, Optional ByVal SQLDatabase As String = "", Optional ByVal UserId As String = "", Optional ByVal Password As String = "") As String >> Try >> Select Case ConnectType >> Case ConnectionTypes.OLEDB_VFP_FreeTable >> Return "Provider=vfpoledb.1;Data Source=" & DataSource & ";Collating Sequence=general" >> Case ConnectionTypes.OLEDB_VFP_DBC >> Return "Provider=vfpoledb.1;Data Source=" & DataSource & ";Collating Sequence=machine" >> Case ConnectionTypes.OLEDB_Access >> Return "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DataSource & ";User Id=" & UserId & ";Password=" & Password & ";" >> Case ConnectionTypes.OLEDB_Excel >> Return "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DataSource & ";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1""" >> Case ConnectionTypes.SQL_Standard >> Return "Data Source=" & DataSource & ";Initial Catalog=" & SQLDatabase & ";User Id=" & UserId & ";Password=" & Password & ";" >> Case ConnectionTypes.SQL_Trusted >> Return "Data Source=" & DataSource & ";Initial Catalog=" & SQLDatabase & ";Integrated Security=SSPI;" >> Case Else >> Throw New Exception("Connection Type Not Recognized") >> End Select >> Catch ex As Exception >> Throw ex >> End Try >> End Function >> >>