all groups > dotnet windows forms databinding > december 2004 >
You're in the

dotnet windows forms databinding

group:

Autoincrement value.. Why in new row? How do I get the next value?


Autoincrement value.. Why in new row? How do I get the next value? Rollasoc
12/15/2004 4:47:43 PM
dotnet windows forms databinding:
Hi,

I have created added a Dataset to my project. In this dataset I have added
a table which has an ID column. I have set this column to autoincrement.
The dataset will be persisted using XML in a flat file.

When I try to add a new row in code, it is expecting an ID in the add row
function. I would have thought it would be more useful to add the row and
it reutrn me the value. How can I achieve this?

e.g.
DS_Customer dsCustomer = new DS_DN9848();

int CustomerNext = ?????????????????????????????????;

dsCustomer.CustomerTable.AddCustomerRow(CustomerNext , CustomerName,
CustomerAddress, CustomerPhone);

How do I find out what the next customer ID is (so I can populate
CustomerNext)?

Rollasoc
PS This is a single user application.





Re: Autoincrement value.. Why in new row? How do I get the next value? Colin R. R. Johnson
12/15/2004 11:53:59 PM
Hi Rollasoc,

It looks to me like what you want is something like:

DS_Customer.CustomerTableRow newRow =
dsCustomer.CustomerTable.NewCustomerTableRow(); // create a new row

// populate the row
newRow.CustomerName = customerName;
newRow.CustomerAddress = customerAddress;
newRow.CustomerPhone = customerPhone;

// add the row to the table
dsCustomer.CustomerTable.AddCustomerTableRow(newRow);

newRow.CustomerNext will equal the new value from the auto increment field.

Hope that helps.

[quoted text, click to view]

--
Colin R. R. Johnson
C&J Solutions
Re: Autoincrement value.. Why in new row? How do I get the next value? Rollasoc
12/16/2004 1:00:31 PM
Colin,

Unfortunatly, there is no default constructor to use.

Rollasoc


[quoted text, click to view]

Re: Autoincrement value.. Why in new row? How do I get the next value? Rollasoc
12/16/2004 3:25:04 PM
Colin,

Ok, I've sussed it now.... Your code was correct, I was just having a
blonde moment and clicked on the wrong function in the inttelisense.

Thank you very much..

Rollasoc


[quoted text, click to view]

AddThis Social Bookmark Button