473,626 Members | 3,353 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataSet Merge method

1 New Member
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 connectionStrin g = @"Provider=Micr osoft.Jet.OLEDB .4.0;Data Source=D:\Siebe l\Test1.xls;Ext ended Properties=""Ex cel 8.0;HDR=YES;""" ;

string connectionStrin g1 = @"Provider=Micr osoft.Jet.OLEDB .4.0;Data Source=D:\Siebe l\Test2.xls;Ext ended Properties=""Ex cel 8.0;HDR=YES;""" ;

string connectionStrin g2 = @"Provider=Micr osoft.Jet.OLEDB .4.0;Data Source=D:\Siebe l\Test3.xls;Ext ended Properties=""Ex cel 8.0;HDR=YES;""" ;

DataSet ds = new DataSet();


DataSet ds1 = new DataSet();


System.Data.Ole Db.OleDbDataAda pter da =
new System.Data.Ole Db.OleDbDataAda pter("SELECT B FROM [Sheet1$]", connectionStrin g);

System.Data.Ole Db.OleDbDataAda pter daDest =
new System.Data.Ole Db.OleDbDataAda pter("SELECT B FROM [Sheet1$]", connectionStrin g1);

System.Data.Ole Db.OleDbDataAda pter da2 =
new System.Data.Ole Db.OleDbDataAda pter("SELECT * FROM [Sheet1$]", connectionStrin g2);

da.AcceptChange sDuringFill = false;

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

ds.Merge(ds1, true, MissingSchemaAc tion.Ignore);

System.Data.Ole Db.OleDbCommand Builder x = new System.Data.Ole Db.OleDbCommand Builder(da2);

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


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

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

Similar topics

4
4443
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 = ? AND MAFLD = ? It populates a data adapter in which at that point I open a new dataset and I have the parameters and such setup including the proper update, insert and delete commands created as well. It works great I can update and insert and...
1
1718
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 maniuplate (update some records) 3) Now, merge this copied dataset back into the original dataset (using the Merge method) 4) Now display this original dataset in a datagrid to prove the data has
7
2210
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 constraints every which way. Dataset1.Merge(Dataset2) Can anyone shed some light on merging, I thought it was going to be simple, but there I go thinking again.
2
2103
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( myCustomDataSet.MyTable, bPreserveChanges, MissingSchemaAction.Add ); ds.AcceptChanges(); // tried with and without this line
2
2818
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 way to keep the data in sync? I want to avoid that I transfer the entire dataset all the time. Is there a way just to send/receive the changes?
3
3114
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 them, how do I go about doing that ? This is a search query, so I do not want to create another temp table to do this, any idea's please. Imran.
5
1109
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
947
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 insert new row if there is no match. To keep it simple, please assume the schema is same. I have one dataset Dataset A from a legacy db as the source and have another dataset B with a new db as the source. The dataset A and dataset B has the same...
4
2245
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 person with Pocket PC. 3. XML file is used to populate DataSet on the Pocket PC. 4. User adds new rows, changes values, deletes some rows. 5. Altered dataset is saved back to XML file. 6. XML file is given back to the person who initially created...
2
1852
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 a file operation) and the resulting sql query based on the contents of said dataset. Effectively I would end up with two dataset tables in my application. If I were writing this to action from two tables it would be thus: SELECT ds.id, db.*
0
8265
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8196
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8364
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7193
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5574
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4197
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1808
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1511
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.