Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Data Binding / December 2004

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rollasoc - 15 Dec 2004 16:47 GMT
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.
Colin R. R. Johnson - 16 Dec 2004 04:53 GMT
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.

> Hi,
>
[quoted text clipped - 19 lines]
> Rollasoc
> PS This is a single user application.

Signature

Colin R. R. Johnson
C&J Solutions
- Remember, everything you see on screen is but ones and zeroes.

Rollasoc - 16 Dec 2004 13:00 GMT
Colin,

Unfortunatly, there is no default constructor to use.

Rollasoc

> Hi Rollasoc,
>
[quoted text clipped - 38 lines]
> > Rollasoc
> > PS This is a single user application.
Rollasoc - 16 Dec 2004 15:25 GMT
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

> Colin,
>
[quoted text clipped - 49 lines]
> > > Rollasoc
> > > PS This is a single user application.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.