Combining two datasets...

mike55

Well-known member
Joined
Mar 26, 2004
Messages
726
Location
Ireland
Hi all,

I have two datasets, the first dataset contains the data for a company selected directly from the database (The first column is an auto-incrementing field). The second dataset contains data that was extracted from a .CSV file. What I need to do is to take the data that was uploaded and insert it into the database dataset, and then update the database with the combined dataset.

In order to enable updating the database I am using the command builder. The problems that I am having is combining both datasets together. My plan was to originally take each record from the .CSV file and firstly check to see if the customer mobile number was in the dataset from the database. If it was then the operation was an update, else it was an insert.
Code:
dim drwSelect as DataRow()
drwSelect = dstDatabase.Tables(0).Select("MobileNumb=" & selectResult & "")
if drwSelect.Length = 0 Then
 Insert operation.
dstDatabase.Tables(0).LoadDataRow(drwSelect, True)
Else
 Update operation.
End If

Once all the insert and update operations have been completed, I would then Update the database.

Mike55.
 
Ok,

I have added a primary key to each dataset, and I have used the same primary key for both datasets. I then use the merge command with both datasets as follows:
Code:
dstDatabase.Merge(dstCSVFile, False, MissingSchemaAction.Add)

I am getting the following error:
"<taget>.MobileNumb and <source>.MobileNumb have conflicting properties: Datatype property mismatch"

Any suggestions on what is causing this problem?

Mike55.
 
When merging two datasets, must they have the exact same structure, or can I get away with them having 4 or 5 the same columns?

Mike55.
 
They do not have to be the exact same structure, the things that have thrown off my merge before is the table name not matching or the column name (unbelievably so) not have the same case in one as in the other. The field length, prescion, default values may be a source too...Merge Ive found isnt very forgiving. Ive also had better luck with strongly typed datasets merging then on-the-fly datasets.
 
bri189a said:
They do not have to be the exact same structure, the things that have thrown off my merge before is the table name not matching or the column name (unbelievably so) not have the same case in one as in the other. The field length, prescion, default values may be a source too...Merge Ive found isnt very forgiving. Ive also had better luck with strongly typed datasets merging then on-the-fly datasets.

Ok, both my tables have the same name, they also have the same datatype, and the same column names; therefore it must be down to field length, precision, and default values.

Mike55.
 
Back
Top