Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sync'ing an untyped dataset with an untyped dataset

Status
Not open for further replies.

jwarmuth

IS-IT--Management
Sep 22, 2001
151
CA
I'm having trouble with a column in my datasets.

I have a typed dataset, created from one of my tables in my SQL DB. I have an untyped dataset that contains my data. When I try to 'merge' the datasets I'm getting an exception because the typed DS has a unique key column that cannot be null.

Let me give a simplified example;

My typed DS has two columns:
stkD_ID - autoincrements, unique, int
stkD_Name - string

My untyped DS has two columns;
stkD_ID - ????
stkD_Name - string


I want to merge the data from the untyped DS into the typed DS having the unique indentifier created upon record submission into the DB (when I call the data adapater update method), not when I add records into my datasets. It's the database that tracks and cares about the unique ID's, not the application.

How do I setup the column in my untyped dataset to sync with my typed dataset? Other than this unique ID column, the datacolumns are identical.

TIA!!

Jeff W.
MCSE, CNE
 
DANG IT!! I misspelled the title of this thread. :/

Should be...

"Sync'ing a typed dataset with an untyped dataset"

Jeff W.
MCSE, CNE
 
how are you merging the datatables?

You may have to loop through the rows collection of the untyped-dataset (for each row as datarow in datatable.rows) and add the row to the typed dataset. One at a time.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Hmmm, curious as to how that would avoid my misalignment with the primary column.

In retrospect, I didnt' explain my problem very well. I should have just asked how to create a column in an untyped dataset that would relate to a primary key column in an SQL DB.

Since the SQL server handles the autoincrement task, the application only needs to be able to send the changes up into the database.

Jeff W.
MCSE, CNE
 
oh, just something like this: (No IDE, from memory, so test with a grain of salt)

Code:
dim dc as new datacolumn(gettype(integer), "PrimaryKeyName")
dim PKs() as datacolumn = (dc)
dataset.tables("TableName").Cols.Add(dc)
dataset.primarykey = PKs

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top