G
Guest
My question: "What is the correct connection object to use in VS 2005 for a
text connection?" will need some background. I am placing code at the end
showing how I am reading data from a text file (comma delimited) into a
dataset. My problem is that the connection object I have used in the past
seems to be outdated:
[JET oledb 4.0 with the following modifications to the connection object:
Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Engine Type=96;Extended
Properties="Text;HDR=YES;Data Source=C:\vb6\myfile.txt;Jet OLEDB
atabase
Locking Mode=0...]
I want to use the System.Data.SQLClient exclusively without any OLE objects
but cannot find the required connection object that will allow me to write
back to the text file. Perhaps it isn't doable. Code to create dataset=>
'=========================
Public Function FlatFileDataSource(ByVal sFile As String) As DataTable
'grabs flat file and places into dataset
Dim SR As StreamReader
Dim ReadBeginToEnd As String
Dim dt As New DataTable
Dim Rowz As Array
Dim row As DataRow
Dim bFirstlineHeader As Boolean
Dim S As String
Dim sTerminator As String = vbNullString
Dim s As String
SR = New StreamReader(sFile)
ReadBeginToEnd = SR.ReadToEnd
SR.Close()
SR.Dispose()
Rowz = Split(ReadBeginToEnd, vbNewLine)
s = Rowz(0)
Dim sArr As Array = Split(s, ",", -1)
For Each s In sArr
dt.Columns.Add(New DataColumn(s))
Next
For Each S In Rowz
If Not bFirstlineHeader Then
bFirstlineHeader = True
Else
row = dt.NewRow
sTerminator = Replace(S, vbNewLine, "")
row.ItemArray = Split(sTerminator, ",", -1)
dt.Rows.Add(row)
End If
Next
FlatFileDataSource = dt
End Function
--
Regards,
Jamie
Incidentally - I accidently posted this in a VB forum. I didn't realize
there was a difference between VB and VB.NET. Apology here for any confusion
I have caused.
text connection?" will need some background. I am placing code at the end
showing how I am reading data from a text file (comma delimited) into a
dataset. My problem is that the connection object I have used in the past
seems to be outdated:
[JET oledb 4.0 with the following modifications to the connection object:
Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Engine Type=96;Extended
Properties="Text;HDR=YES;Data Source=C:\vb6\myfile.txt;Jet OLEDB

Locking Mode=0...]
I want to use the System.Data.SQLClient exclusively without any OLE objects
but cannot find the required connection object that will allow me to write
back to the text file. Perhaps it isn't doable. Code to create dataset=>
'=========================
Public Function FlatFileDataSource(ByVal sFile As String) As DataTable
'grabs flat file and places into dataset
Dim SR As StreamReader
Dim ReadBeginToEnd As String
Dim dt As New DataTable
Dim Rowz As Array
Dim row As DataRow
Dim bFirstlineHeader As Boolean
Dim S As String
Dim sTerminator As String = vbNullString
Dim s As String
SR = New StreamReader(sFile)
ReadBeginToEnd = SR.ReadToEnd
SR.Close()
SR.Dispose()
Rowz = Split(ReadBeginToEnd, vbNewLine)
s = Rowz(0)
Dim sArr As Array = Split(s, ",", -1)
For Each s In sArr
dt.Columns.Add(New DataColumn(s))
Next
For Each S In Rowz
If Not bFirstlineHeader Then
bFirstlineHeader = True
Else
row = dt.NewRow
sTerminator = Replace(S, vbNewLine, "")
row.ItemArray = Split(sTerminator, ",", -1)
dt.Rows.Add(row)
End If
Next
FlatFileDataSource = dt
End Function
--
Regards,
Jamie
Incidentally - I accidently posted this in a VB forum. I didn't realize
there was a difference between VB and VB.NET. Apology here for any confusion
I have caused.