473,408 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Legacy Connection Object - I need a new one

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 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.
Apr 20 '06 #1
3 1343

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

Apr 20 '06 #2
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

--
Regards,
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

Apr 20 '06 #3

thejamie wrote:
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


Thanks, I must already owe Carl Prothman about ten drinks from back in
the ADO days, so another won't hurt :)

--
Larry Lard
Replies to group please

Apr 20 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: steve clark | last post by:
We've noticed that invocations of legacy C++ COM DLLs from .NET (Managed C++ or C#) desktop applications is quite a bit slower than the same calls from good old native C++. Does anybody have...
2
by: Rajiv Kumar | last post by:
Hi, I am a Java prof for last 5 years and have delivered many enterprise application using J2EE. Now my company is making headway in the .NET area of the market, and I am trying to sort out few...
3
by: Sai Kit Tong | last post by:
I posted for help on legacy code interface 2 days ago. Probably I didn't make it clear in my original mail. I got a couple of answers but none of them address my issues directly (See attached...
3
by: Geoff | last post by:
I need to keep a few VB6 tcpClients active, but have them talk to a dotNet tcpServer/tcpListener. The "Server"/Listener is running as a Plugin, and needs to respond to "outside requests". The...
1
by: gregory_may | last post by:
I have a mixed ASP.NET and legacy ASP application. Right now, the .ASP pages use a mix of Hard Coded connection strings and an "Global Included" file. I would like to use the connection string...
1
by: omantawy | last post by:
Hi, I have some legacy ASP web applications that use an unmanaged COM component to connect to a third party application. The third part application has moved to the managed code in the current...
4
by: Jason Madison | last post by:
I would like to create a .net application that still uses a few screens from an old legacy application we have. I can list records from the database in my .net app, but when it comes to making...
12
by: Light | last post by:
Hi all, I posted this question in the sqlserver.newusers group but I am not getting any response there so I am going to try it on the fine folks here:). I inherited some legacy ASP codes in my...
0
by: SvenV | last post by:
Hello, I'm quite new to WCF and want to use it in a project that I'm currently working on. I need some advice though. The legacy application that I currently have created an xml file with data....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.