473,396 Members | 1,858 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,396 software developers and data experts.

vb.net CSV import into sql express 2005

I'm a newbie.

I'm writing my first VB.net program. Our company gets a weekly csv file from the head office that contains a list of all employees and their contact information.

Im trying to write an application that can be used by our branch office that will automatically import the csv file into SQL express 2005.

Using this site and others I've figured out how to import the csv file (Employees.csv) into a dataset and how to use sqlBulkCopy to write the data to the employee table in the sql 2005 database. But this leaves me with 2 problems that I'm totally stuck on.

1. If an employee record already exists in the sql database then the sqlBulkcopy stops inserting and causes an error, the employee ID is the promary key in the sql db.

2. I also need to update any existing employee record in the sql db to the data that is in the csv file.

So... I'm trying to come up with a method to fix both of these problems. If anyone has a solution please provide some sample code for it as I'm very new on everthing.

TIA
Jul 3 '07 #1
2 7482
jai80
30
I'm a newbie.

I'm writing my first VB.net program. Our company gets a weekly csv file from the head office that contains a list of all employees and their contact information.

Im trying to write an application that can be used by our branch office that will automatically import the csv file into SQL express 2005.

Using this site and others I've figured out how to import the csv file (Employees.csv) into a dataset and how to use sqlBulkCopy to write the data to the employee table in the sql 2005 database. But this leaves me with 2 problems that I'm totally stuck on.

1. If an employee record already exists in the sql database then the sqlBulkcopy stops inserting and causes an error, the employee ID is the promary key in the sql db.

2. I also need to update any existing employee record in the sql db to the data that is in the csv file.

So... I'm trying to come up with a method to fix both of these problems. If anyone has a solution please provide some sample code for it as I'm very new on everthing.

TIA
Hi,

I am working in CSV file using asp.net. I came across the following problem and am stuck with it. can u assist me coz u have worked in the same grnd.

this is the sample batch of records that i have in my csv file,

1,'KS010','S',09,345
2,'KS011','S',09,346
3,'KS012','S',09,347
4,'KS013','S',09,348
01,'AS010','S',09,345
02,'AS011','S',09,346
07,'AS012','S',09,347
08,'AS013','S',09,348
............................
..................

while trying to retrieve the above batch of records from the CSV file using the dataset and to write the data to my sql table, i endup getting the records in the below pattern...

1,'10','S',09,345
2,'11','S',09,346
3,'12','S',09,347
4,'13','S',09,348
01,'AS010','S',09,345
02,'AS011','S',09,346
07,'AS012','S',09,347
08,'AS013','S',09,348

the code value that started with KS0.., gets truncated and i get only 10,11,12,13; whereas for the next set of records that has the code starting with AS0..,it is returned without any truncation. i am able to get the full code value,that you can see from the above set of records. would be of great help if u assist me with some solution. Thanks in advance. hope i've provided a clear description of the problem am facing.

cheers,
jai
Jul 4 '07 #2
I'm a newbie.

I'm writing my first VB.net program. Our company gets a weekly csv file from the head office that contains a list of all employees and their contact information.

Im trying to write an application that can be used by our branch office that will automatically import the csv file into SQL express 2005.

Using this site and others I've figured out how to import the csv file (Employees.csv) into a dataset and how to use sqlBulkCopy to write the data to the employee table in the sql 2005 database. But this leaves me with 2 problems that I'm totally stuck on.

1. If an employee record already exists in the sql database then the sqlBulkcopy stops inserting and causes an error, the employee ID is the promary key in the sql db.

2. I also need to update any existing employee record in the sql db to the data that is in the csv file.

So... I'm trying to come up with a method to fix both of these problems. If anyone has a solution please provide some sample code for it as I'm very new on everthing.

TIA
I am trying to write a similar program but can not get it to connect to my SQL server. Can you please post your code?
Aug 15 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: David Berry | last post by:
Hi All. I'm looking for any help or sample code that can show me how to make a file import wizard in ASP.NET (VB preferred) like the one that MS Access uses. I'm working on a web site where the...
8
by: Peter Oliphant | last post by:
I have been using VS C++.NET 2005 Express as our company waits for the MSDN full version to arrive. It is a pretty amazing free tool! My question is I'd like to also do some VS C#.NET stuff too....
1
by: Peter | last post by:
I've purchased VS.NET 2005 Standard and have tried to install SQL Server 2005 Express, but get the following error in the error log. Please could someone help me.... Microsoft SQL Server 2005...
0
by: biederax | last post by:
Hello, I want to import a txt-file with semicolon as separator from a workstation to my MS SQL 2005 Express Edition server via batch script. After import the user should get a message, like...
9
by: cabrenner | last post by:
I am new to SQL Server, and migrating part of an Access application to SSE. I am trying to insert a comma delimited file into SSE 2005. I am able to run a BULK INSERT statement on a simple file,...
3
by: Steve | last post by:
Hi All I downloaded Sql server 2005 express SP2 and attempted to modify the Bootstrapper package files as I did with SP1 When i try to install SQL server as part of my VS 2005 deployment app I...
1
by: fanoftvb | last post by:
Hi, i'm using SQL server 2005 express and want to import and export my data. However, when i run the C:\Program Files\Microsoft SQL Server\90\DTS\Binn\DTSWizard.exe , i cannot find the DTSWizard.exe....
3
by: Erwin Moller | last post by:
Hi Group, I developed a intranet site using MSSQL7/win2000 some time ago. The target environment used MSSQL2000/8. We were (almost painlessly) able to import the db-scheme and data from 7 to 8....
0
by: kishjeff | last post by:
Hi. I used to have sql server 2000 and used dts to import data from oracle databases. Now I've been using sql server 2005 express, and don't see how to import anymore. Is DTS not available with...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.