|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Legacy Connection Object - I need a new onetext 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:Database 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. thejamie wrote:
> My question: "What is the correct connection object to use in VS 2005 for a That's (only) for talking to Microsoft SQL Server. OleDbClient is for> 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:Database > Locking Mode=0...] > I want to use the System.Data.SQLClient talking to everything else. <http://www.connectionstring.com> suggets this for an OLE DB connection to a text file: "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\txtFilesFolder\;Extended Properties=""text;HDR=Yes;FMT=Delimited""" "HDR=Yes;" indicates that the first row contains columnnames, not data so I'd suggest that what you have at the moment is fine. -- Larry Lard Replies to group please Larry,
Thanks. I should have realized that. My focus was on keeping code clean and not whether it was practical. Incidentally, the link you gave me for connection strings is horribly commercial. Carl Prothman's seems better to me, at least. http://www.carlprothman.net/Default.aspx?tabid=81 -- Show quoteHide quoteRegards, Jamie "Larry Lard" wrote: > > thejamie wrote: > > 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:Database > > Locking Mode=0...] > > I want to use the System.Data.SQLClient > > That's (only) for talking to Microsoft SQL Server. OleDbClient is for > talking to everything else. <http://www.connectionstring.com> suggets > this for an OLE DB connection to a text file: > > "Provider=Microsoft.Jet.OLEDB.4.0;Data > Source=c:\txtFilesFolder\;Extended > Properties=""text;HDR=Yes;FMT=Delimited""" > > "HDR=Yes;" indicates that the first row contains columnnames, not > data > > so I'd suggest that what you have at the moment is fine. > > -- > Larry Lard > Replies to group please > > thejamie wrote:
> Larry, Thanks, I must already owe Carl Prothman about ten drinks from back in> > Thanks. I should have realized that. My focus was on keeping code clean > and not whether it was practical. Incidentally, the link you gave me for > connection strings is horribly commercial. Carl Prothman's seems better to > me, at least. > http://www.carlprothman.net/Default.aspx?tabid=81 the ADO days, so another won't hurt :) -- Larry Lard Replies to group please
How to extract multiple occurrences of a substring
Merging data received via TCP Textbox data entry validation Finding A Record in a Dataset by index Form1 can't getfocus again... Waiting for ThreadPool Execute something stored in a variable IE Privacy - DNS Problem - ASP.NET textbox enter or GotFocus Are there any tools that can generate call graph for Visual Basic .NET source codes? |
|||||||||||||||||||||||