mike55 Posted December 28, 2005 Posted December 28, 2005 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. Quote 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)
mike55 Posted December 28, 2005 Author Posted December 28, 2005 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. Quote 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)
mike55 Posted December 29, 2005 Author Posted December 29, 2005 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. Quote 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)
bri189a Posted December 30, 2005 Posted December 30, 2005 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. Quote
mike55 Posted December 30, 2005 Author Posted December 30, 2005 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. Quote 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)
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.