Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

SQL Bulk Copy in C# using Cinchoo CSVReader

$
0
0

Good day all. I'm in a bit of a stuck place here. Let me try to explain this as clearly as possible. I have a .CSV file with column headers like this:

User ID, First Name, Last Name, City, State, Zip Code

The database fields are like this:

User_ID, FirstName, LastName, City, State, Zip

Trying to use Cinchoo CSVReader class and was able to pull the csv headers and data into the memory stream. However, when it tries the Bulk Copy Insert, it squawks saying the dynamic table columns are not found. What I'm trying to do in-code is map the csvreader columns to database columns for my bulk insert class. Here's the code:

C#
try{if(System.IO.File.Exists(filePath)){EventLog.WriteEntry("Reading File from "+filePath.ToString());stringconnectionstring=ConfigurationManager.ConnectionStrings["connStr"].ConnectionString.ToString();EventLog....

Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>