Hello everyone,
Im new to this forum and I have a question about the use of ADO.NET within VB.NET (2010 Express version).
On the internet I found a great example project (homeandlearn) to learn how to work with ADO.NET from VB.NET. Like many others I formerly worked with DAO and I'm moving towards ADO.NET now.
The DataBase project, using a Connection$ against an MS Access 2007 DB through OLE_DB provider works partially fine already. I use a CommandBuilder CB to update data from the Dataset DS to the DataBase and for the DB-fields in general this works fine, except for the ID-Field which is managed by Access itself using Autonum. The recordnumbers generated by Access are not passed back to the Dataset unless I start a complete new DataSet Fill procedure after each new added record!
My Question : Does anybody know , when I add a new record, how I can get the recordnr asigned by MS Access back into my current dataset (so also showing on my app.form) without starting a new DS-Fill procedure after adding a new record?
I temporary solved this by labeling all new record recordnrs on the screen with '[New]'. After starting a complete new DS-Fill the recordnrs are then exposed on the form again.
This is how I add a new record :
'DS contains the dataset, DA is the data-adapter
dsNewRow = ds.Tables("AddressBook").NewRow()
'Fill in the fields..
ds.Tables("AddressBook").Rows.Add(dsNewRow)
da.Update(ds, "AddressBook")
When i retrieve the ID-field from the DB with [..].item(index) then I notice that the value is NULL, so there is no recordnumber available within the DB yet? When I look from within Access 2007 itself I can see this recordnumber.
Thanks in advance for your reply and greetings,
Valentino
Im new to this forum and I have a question about the use of ADO.NET within VB.NET (2010 Express version).
On the internet I found a great example project (homeandlearn) to learn how to work with ADO.NET from VB.NET. Like many others I formerly worked with DAO and I'm moving towards ADO.NET now.
The DataBase project, using a Connection$ against an MS Access 2007 DB through OLE_DB provider works partially fine already. I use a CommandBuilder CB to update data from the Dataset DS to the DataBase and for the DB-fields in general this works fine, except for the ID-Field which is managed by Access itself using Autonum. The recordnumbers generated by Access are not passed back to the Dataset unless I start a complete new DataSet Fill procedure after each new added record!
My Question : Does anybody know , when I add a new record, how I can get the recordnr asigned by MS Access back into my current dataset (so also showing on my app.form) without starting a new DS-Fill procedure after adding a new record?
I temporary solved this by labeling all new record recordnrs on the screen with '[New]'. After starting a complete new DS-Fill the recordnrs are then exposed on the form again.
This is how I add a new record :
'DS contains the dataset, DA is the data-adapter
dsNewRow = ds.Tables("AddressBook").NewRow()
'Fill in the fields..
ds.Tables("AddressBook").Rows.Add(dsNewRow)
da.Update(ds, "AddressBook")
When i retrieve the ID-field from the DB with [..].item(index) then I notice that the value is NULL, so there is no recordnumber available within the DB yet? When I look from within Access 2007 itself I can see this recordnumber.
Thanks in advance for your reply and greetings,
Valentino