.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links


Posted By:      Posted Date: August 31, 2010    Points: 0   Category :ASP.Net
Hi ,im using sqlbulkcopy to import all the columns and rows in an excel file to a database. My question is, if my database has 1 more extra column which i have to map it to a session variable and that extra column in the database is not found in the excel, isit possible to do something like dat? can anyone advice? thanks!

View Complete Post

More Related Resource Links

SqlBulkCopy: the locale id '0' of the source column '<column name> ' and the locale id '1



I have same issue, can anyone help?


The locale id '0' of the source column 'StandardName' and the locale id '1033' of the destination column 'StandardName' do not match.

I have check source and destination table both are same. Please help me.


I am using this code:                             DateTime dDated = ( DateTime )Globals.dtSets.Tables[ "mm_" + symbol ].Rows[ 0 ][ "dateTimed" ];                            dated = ( DateTime )Globals.dtSets.Tables[ "mm_" + symbol ].Rows[ Globals.dtSets.Tables[                                                                 "mm_" + symbol ].Rows.Count - 1 ][ "dateTimed" ];                            bool firstRecThere = SqlSaveAndRetrieve.doesRecordExistsInAnalytical ( symbol, dDated, "mm_" );                    &n

C# .NET SqlBulkCopy and redirecting error rows

I am using SqlBulkCopy within a Script Task to extract data from an Oracle server into SQL Server. Is there a way to redirect error rows with code or otherwise from the SqlBulkCopy? I have implemented this before using a regular Copy Column task and redirecting the Destination Error into a different table of all data type varchar. So I am trying to make something similar with the script task and SqlBulkCopy. Any suggestions? ThanksYou are so wise...like a miniature budha covered in fur. -Anchorman

C# .NET SqlBulkCopy inserted row count

Im using a Script task to extract data from Oracle into SQL Server using SqlBulkCopy. I need to get a count of rows inserted by the SqlBulkCopy and cant figure out how to do this. I did try the SqlRowsCopied event, but it looks like I need to fill the NotifyAfter property to get the SqlRowsCopied to fire. I am confused because if I have say 11 rows in the source, and set the NotifyAfter to 100 it doesnt fire. If I set the NotifyAfter property to 10, then the event fires and I get the count of 10 and not 11 (however, 11 rows get inserted). Is there an efficient way to get the RowsCopied for the SqlBulkCopy?  ThanksYou are so wise...like a miniature budha covered in fur. -Anchorman

sqlbulkcopy not working for defaulvalue of table in sql server 2005



i am facing problem in sqlbulkcopy function.

in database i have one ID column in where i am generating unique id through db function.

now for insert query its working properly but when i am using Sqlbulkcopy the default value fuction not executing.

please help.

How do I insure that SqlBulkCopy resources are cleaned up after use?


If I create a new SqlBulkCopy object, VS 2008 and 2010 intellisense does not show it as having a .Dispose() method and if I just type it in the compiler won't allow it. 

Doesn't SqlBulkCopy create unmanaged resources that should be cleaned up by calling .Dispose()?  BOL/VS Help indicate this object implements .Dispose().  Most code examples show this object being declared in a using block, but I don't believe using can do the right thing unless it believes the class has a .Dispose() method.

I tried this as a work around:

SqlBulkCopy bc = null;
try {
	SqlBulkCopy bc = new SqlBulkCopy();
	// do stuff with bc
finally {
	if (bc != null)

This at least compiles (and runs).  However, as I watch my application, which copies a lot of SQL tables, the process's memory usage just keeps growing in task manager.

How do I insu

SqlBulkCopy DATAFILETYPE widechar


hello everybode

i have a csv fle that needs to be imported to sql server

the file includes unicode characters, so i saved it in notepad as unicode

now when i run this in sql it works excellent

INSERT personimps
FROM 'C:\MyImp.csv'
(FIELDTERMINATOR = ',',datafiletype='widechar')

but when using the following in my codebehind in asp.net, i get gibberish where the unicode chars should be

(standard english chars in same file come out ok)

Dim ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & IO.Path.GetDirectoryName(NewFilePath) & ";Extended Properties=""Text;HDR=Yes;DATAFILETYPE='widechar';FMT=Delimited"""
        Dim oOleDbConnection = New OleDbConnection(ConnectionString)
        Dim oOleDbCommand = 

SqlBulkCopy How to Use to Insert Data From text CSV file to Sql Table



I am New to using the  SqlBulkCopy Can any one tell me how to use it and how many rows maximum we can insert using the SqlBulkCopy

how to habdle the  exceptions when bulkcopy inserting

SqlBulkCopy SQL Express 2005 copied to few rows



When I try copy some data from remote (ODBC) SQL serverer to local SQL Express using SqlBulkCopy  I saw that I have to few rows.

First I downloading data to dataSet from remote SQL server using ODBC:


OdbcConnection dbConn = new OdbcConnection("DSN=" + settings.ODBC_DSN + ";uid=" + username + ";pwd=" + password);
OdbcDataAdapter dataAdapter = new OdbcDataAdapter();
DataSet dataSet = new DataSet();

 dataAdapter.SelectCommand = new OdbcCommand(sql, dbConn);
 dataAdapter.Fill(dataSet, settings.RECIPES_TABLE_NAME);
catch (Exception ex)



(When I check dataSet during debugging, dataSet object contained proper count of rows)
Next I copy data using SqlBulkCopy object:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend