DataSource Controls :: SqlBulkCopy + Key Violations?
Jan 18, 2010
I am confused by some behaviour I am experiencing when I use the SqlBulkCopy command.I have two tables in my SQL server database that I use to upload 2 tables of data from an excel workbook. The primary key of each table is customer account number, the first table being a table of accounts, the second being a table of details with the account number linking the 2 tables creating a one-to-one relationship.The bulk copy works a treat apart from one rather problematic situation I have found when performing error handling. If I put an account into the details table that does not appear in the customer table, instead of causing key violation errors it still adds the entry - I was under the impression that this was impossible?
If I go edit the entry using SQL Server management studio, I cannot change account numbers to anything that does not exist in the other table thus showing that the relationship exists and works when using standard update SQL.Does anyone have any idea why and how data that violates key violations is allowed through when I use SqlBulkCopy?
View 1 Replies
Similar Messages:
May 5, 2010
I'm using the SqlBulkCopy within my asp.net C# web form. I'm able to upload my excel file, but if the first row has any blank cells in it, that colum does not upload, I was wondering if anyone had any luck in looking for NULL/Blank cells and if so how did you handle them for the insert into the database?
View 6 Replies
Mar 17, 2010
I want to bulk insert the datatable data into database.I can not use sqlbulkcopy class.since,I am using oledb.
View 3 Replies
Apr 30, 2010
I code to exec a store procedre (sp_truncate) to truncate 10tables and using sqlBulkCopy to download a huge data. Both them are working fine.Now I want to use transaction with application (not in store procedure) torollback truncate tables if download is failed.Is it possible to use transaction to work with these two steps?
View 1 Replies
Dec 26, 2010
I'm using SqlBulkCopy to restore tables from xml backups. One of the table backup is ~200MB large and has a lot of records.
I'm having error:
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
View 2 Replies
Mar 26, 2010
I read a CSV file into a DataTable.The DataTable in the first image shows each column and type.The types are exactly what they are supposed to be and the data loaded all the rows it was supposed to load.From the second screen shot you can see the database table. SqlBulkCopy is supposed to map column names to database columns by default.According to that logic each column matches up exactly to the database and the column types also match.However,when I run the command it errors on the first row with:
"The given value of type String from the data source cannot be converted to type decimal of the specified target column."
Here is the StackTrace:
"at System.Data.SqlClient.SqlBulkCopy.ConvertValue(Object value, _SqlMetaData metadata) at System.Data.SqlClient.SqlBulkCopy.WriteToServerInternal() at System.Data.SqlClient.SqlBulkCopy.WriteRowSourceToServer(Int32 columnCount) at
[code]...
Anyone have any ideas why this will not import correctly?
http://www.daviddelella.com/Images/Image1.jpg
http://www.daviddelella.com/Images/Image2.jpg
View 4 Replies
Feb 19, 2010
I am attempting to use SqlBulkCopy to import data from an XML document. I receive the following error when executing WriteToServer: Invalid cast from 'System.String' to 'System.Guid'
View 1 Replies
May 7, 2015
How to use SqlBulkCopy for import excel data into windows with high performance.
E.g.: using SqlBulkcopy.TableLock options
View 1 Replies
Nov 8, 2010
Using sql server 2005 and vb.net 2005.I'm creating a .net console application where I am doing a SqlBulkCopy from a non-sql server db to a sql server db table and on the call for the bulk insert:
[Code]....
I'm getting a time out error after around 1 minute, however I set BulkCopyTimeout (see above) to 100 minutes, the error:
<ERROR>
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
</ERROR>
Has anyone experienced this and how to fix this or how do I change the timeout so I dont get this error?
View 1 Replies
Mar 9, 2011
I'm successfully using SqlBulkCopy to import spreadsheet data.
I am trying to add 2 additional fields,'UserID' and the specific 'employerID' whom they're logged in as.
Both these ID's are on the page. However how do I tag them on to my column mappings statement?
These ID's aren't on the spreadsheet but I need to know whose imported the data and from where
The columnMappings structure:
[Code]....
View 5 Replies
Dec 23, 2010
I am impoting data from CSV file to my sql server database.
I successfully get data into datatable and using the SqlBulkCopy method to import data into database.
It's working fine.
But i want that if record id is exists then update the record do not insert that record.
View 6 Replies
May 12, 2010
I have a customized data import executable in .NET 3.5 which the SqlBulkCopy to basically do faster inserts on large amounts of data. The app basically takes an input file, massages the data and bulk uploads it into a SQL Server 2000. It was written by a consultant who was building it with a SQL 2008 database environment. Would that env difference be causing this? SQL 2000 does have the bcp utility which is what BulkCopy is based on. So, When we ran this, it triggered a Deadlock error.
Error details: Transaction (Process ID 58) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
I've tried numerous ways to try to resolve it. like temporarily setting the connection string variable MultipleActiveResultSets=true, which wasn't ideal, but it still gives a Deadlock error. I also made sure it wasn't a connection time out problem. here's the function.
/// <summary>
/// Bulks the insert.
/// </summary>[code].....
View 4 Replies
May 7, 2015
i am making bulkcopy from excel sheet to database and it is working fine , but my requirement is , i have previously inserted column in excel and other columns are blank therefore i want to update the table using sqlbulkcopy . how to perform it.
View 1 Replies
Jun 16, 2015
I do not want to insert duplicate values in sql serve if values is exists in DB and excel value be skip.
View 1 Replies
Oct 22, 2010
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.
View 3 Replies
Oct 21, 2015
I am new in asp.net..My Problem is i have 3 textboxes..
in first text box i enter A1,
Second Textbox i enter 3,
Third Textbox i enter 5
after button click i want to store
A1B1,A1B2,A1B3 as per second textbox i enter 3
A1C1,A1C2,A1C3,A1C4,A1C5 as per Third Textbox i enter 5
how to generate the above rows and how to save in database
View 1 Replies
Dec 23, 2015
I'm using SqlBulkCopy to load large file into databse, but a file bigger than 200k give me an error outofmemoryexception. Is there any way to append data into database from a file splitted in two. the first time I can use SqlBulkCopy, but to append second file into my table.
View 1 Replies
Mar 16, 2011
I would like to use a progress bar with SqlBulkCopy, but am unable to find any examples. The solution needs to have taken into consideration using SqlBulkCopy for displaying percentage copied to SqlServer.
View 1 Replies
Mar 10, 2011
i have problem white Object datasource. i have a multi-tier Application that include common layer ,DAL Layer,business logic and persantation layerwhen i add a object datasource to my page, it bring me only common layer classes . but i want use bisuiness layer classes what do i do ?
View 1 Replies
May 20, 2010
I have several web forms which use a GridView linked to a DataSource control which is defined at design time as follows:
<cc1:pgsqldatasource
id="dsStates"
runat="server"
connectionstring="<%$ ConnectionStrings:PgSqlConnection %>"
oldvaluesparameterformatstring="Original_{0}"
providername="<%$ ConnectionStrings:PgSqlConnection.ProviderName %>" >
</cc1:pgsqldatasource>
As you can see, the connectionstring parameter is defined to a specific connection string name and I need to be able to set such a parameter to a different value, for example, to a session variable content.
View 1 Replies
Nov 15, 2010
i am trying to create connection using OLEDB connection in my app. but i am not able to create the connection as in datasource i want to use Server.mappath, but cudn't find the right method to use it. i am trying to make connection with Access database file. following is code i have tried:
string path = Server.MapPath("~/uploadaccess/Production.mdb");
string ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("~/uploadaccess/Production.mdb")&";";
and also
OleDbConnection myConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & path&";");
and tried this
OleDbConnection myConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("~/uploadaccess/Production.mdb"));
and this is the error i am getting:
Operator '&' cannot be applied to operands of type 'string' and 'string'
View 3 Replies
Oct 27, 2010
I am storing a custom "Organisation" object as a session variable. One of the properties of the Organisation object is "OrganisationID" (integer). I have a DataSource that requires a parameter value to run, and I want to use a SessionParameter to populate this. In a previous version, I stored the OrganisationID directly as a session variable. In that case, I could easily access it like this:
[Code]....
However, how do I now access the OrganisationID property of an "Organisation" type session variable (called "Organisation")? I have tried this, which does not seem to work: <asp:SessionParameter Name="OrganisationID" SessionField="Organisation.OrganisationID" Type="Int32" />
View 2 Replies
Feb 25, 2010
i have two sqldatasource controls. one i use to display data in textbox's ,filter'd by a select parameter in page behind code. Once checked, i want to copy this data to the other datasource ,by selecting checkbox.Then display this data in detailsview control.
At present the two datasource controls declared , render data to the page simultaneously during pageload. I want to first check data in textbox's from first source, before second datasource is rendered to screen. note, both are filtered by a page variable. i wish to leave the textbox datasource control in situ, as other controls and code depend on it.The other detailsview datasource is my problem?
View 1 Replies
Feb 10, 2010
to use a datasource from within another datasource..?
View 8 Replies
Mar 2, 2010
ASP.net SQL datasource C# code behind
I want the webpage to show a message that there is no data selected,
Instead of showing blank details view
here is a picture of blank details view:
[URL=http://img28.imageshack.us/i/errorks.jpg/][IMG]http://img28.imageshack.us/img28/4328/errorks.jpg[/IMG][/URL]
What C# code do i need to use so that, whenever I enter that page, only an error message will show up
instead of the details view ..etc.
View 3 Replies