Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

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.

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Posted

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:

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.

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Posted

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.

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Posted
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 I've found isn't very forgiving. I've also had better luck with strongly typed datasets merging then 'on-the-fly' datasets.
Posted
They do not have to be the exact same structure' date=' 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 I've found isn't very forgiving. I've also had better luck with strongly typed datasets merging then 'on-the-fly' datasets.[/quote']

 

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.

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...