How do you move a comma delimited text file with 3 fields into a SQL 2000 table

  • Thread starter Thread starter Kenneth Koski
  • Start date Start date
K

Kenneth Koski

Hello All,

I have a comma delimited text file, which I would like to move into a
SQL 2000 table . I created a DTS package in SQL Server and saved it as a
VB.bas . I am writting the code in C# and I though that I might be able
to change a few lines and keep the bulk of the code. However , it seems
that there is a pretty big change in how VB is written and how C#.net is
written. Does anyone have an example of using DTS and C# to move a few
hundred records into a SQL Server table?

Thank You in Advance for Your Help,
Ken
 
Hi Kenneth,

Are you going to do this more than once? if not just use the DTS of the SQL
server and that's all
if y ou are planning doing it more than once then I think that it's better
if you do it all in code, something like this:

open file
open DB connection
while ( line=file.ReadLine()!=null )
{
string[] fields = line.Split( new char {','} );
CreateSQL Command
Execute SQL Command
}
close DB connection
close file

I think that it's the best solution in your case

Hope this help,
 
Hi Kenneth,

There is a book talked about how to use Sql Server 2000 DTS in .Net
environment with C#, you can download it from the the link below:
http://www.sqldev.net/dts/DotNETCookBook.htm

Hope this helps,
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: Kenneth Koski <[email protected]>
| X-Newsreader: AspNNTP 1.50 (ActionJackson.com)
| Subject: How do you move a comma delimited text file with 3 fields into a
SQL 2000 table
| Mime-Version: 1.0
| Content-Type: text/plain; charset="us-ascii"
| Content-Transfer-Encoding: 7bit
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Date: Mon, 29 Sep 2003 08:20:01 -0700
| NNTP-Posting-Host: actionjackson133.dsl.frii.net 216.17.147.133
| Lines: 1
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:188001
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
|
| Hello All,
|
| I have a comma delimited text file, which I would like to move into a
| SQL 2000 table . I created a DTS package in SQL Server and saved it as a
| VB.bas . I am writting the code in C# and I though that I might be able
| to change a few lines and keep the bulk of the code. However , it seems
| that there is a pretty big change in how VB is written and how C#.net is
| written. Does anyone have an example of using DTS and C# to move a few
| hundred records into a SQL Server table?
|
| Thank You in Advance for Your Help,
| Ken
|
|
|
| Don't just participate in USENET...get rewarded for it!
|
 
Back
Top