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

DataSet Merge method

Hi,

I am facing an error on calling Datset update method.
Following is my scenario:

There are Three Excel Files Test1.xls,Test2.xls and Test3.xls.

There is data in Test1.xls as under:

B
1
2
3

The data in Test2.xls is:

B
8
9

The Test3.xls is empty with column
B

Now I created two data sets on Test1.xls and Test2.xls and merged both now I want to insert the data in this data set in Text3.xls. But I am getting error
OledbExcpetion was unhandled.

"Syntax error in INSERT INTO statement."

Following is the code:

string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Siebel\Test1.xls;Extended Properties=""Excel 8.0;HDR=YES;""";

string connectionString1 = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Siebel\Test2.xls;Extended Properties=""Excel 8.0;HDR=YES;""";

string connectionString2 = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Siebel\Test3.xls;Extended Properties=""Excel 8.0;HDR=YES;""";

DataSet ds = new DataSet();


DataSet ds1 = new DataSet();


System.Data.OleDb.OleDbDataAdapter da =
new System.Data.OleDb.OleDbDataAdapter("SELECT B FROM [Sheet1$]", connectionString);

System.Data.OleDb.OleDbDataAdapter daDest =
new System.Data.OleDb.OleDbDataAdapter("SELECT B FROM [Sheet1$]", connectionString1);

System.Data.OleDb.OleDbDataAdapter da2 =
new System.Data.OleDb.OleDbDataAdapter("SELECT * FROM [Sheet1$]", connectionString2);

da.AcceptChangesDuringFill = false;

da.Fill(ds);
daDest.Fill(ds1);

ds.Merge(ds1, true, MissingSchemaAction.Ignore);

System.Data.OleDb.OleDbCommandBuilder x = new System.Data.OleDb.OleDbCommandBuilder(da2);

DataSet ds3 = new DataSet();
da2.Fill(ds3);


da2.Update(ds);
May 25 '07 #1
0 884

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

Similar topics

4
by: Steve Donnor | last post by:
Here's my question.. I have a Dataset which has populated a datagrid with information from an AS400 That SQL looks like this "Select MASYS, MAFLD, MADATA, MAEQV from QS36F.MAPDATA WHERE MASYS =...
1
by: Mike Hnatt | last post by:
I'm baffled. My data store (database) is not updating with a refreshed dataset. Here's what is going on: 1) Create a dataset from a table in a database. 2) Create a copy of this dataset and...
7
by: Nitromuse | last post by:
Hello, I'm trying to merge two datsets which both have a common keyed column, and getting nowhere. Do I want to use the keyed column or not? I'm using the following and have tried all the...
2
by: muntyanu | last post by:
Hi all, I have problem when merging existing DataTable into new dataset. DataSet ds = new DataSet(); while ( done ) { // fill myCustomDataSet.MyTable with data ds.Merge(...
2
by: Anthony Malt | last post by:
Hi, my server has a database table. I read this table on the server into a dataset and my client retrieves it through a webservice. No changes on the client and server happen. What's the best...
3
by: Imran Aziz | last post by:
Hello All, I have a dataset that I populate using a SQL Server database, and the second one that I populate using a mySQL Server database, I need to combine the results in memory and then sort...
5
by: vaj | last post by:
Hey, Im creating a system on a pocket pc based on win ce 4.2 and i need to tranfer three datasets to a remote server on the network.Could anyone tell me the easiest way to do this? cheers, -vaj
0
by: srini | last post by:
I am trying to find difference between two tables from two different datasources using dataset concepts. I need to update one of the table if there is a difference in values of the columns and...
4
by: Al | last post by:
I have this scenario: 1. XML file with schema and data is created from SQL Server tables. XML file contains 6 tables, some of them have rows, some of them are empty. 2. XML file is given to the...
2
by: Neil Chambers | last post by:
I am trying to get my head around dataset merging but despite a little research I could still use a pointer (or ten). Basically I want to perform an outer join operation on a dataset (created from...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.