amigo02
Programmer
- Feb 19, 2003
- 109
In my Access database table I have an autonumber field which obviously is automatically given a value when a new record inserted
I use dataset in my asp.net (vb) to update the Datasource but I could not figure out how to read back this autonumber fields value after successfully inserting a record to table.
In other words dataset does not reflect the new value created automatically by database for autonumber field for that specific row after updating the Datasource and thus I have no access to autonumber field which I need to use to update another table.
The code is as follows:
oCommandBuilder = New OleDbCommandBuilder(WarehouseDA)
rowW = ds.Tables("WAREHOUSE").NewRow
Response.Write(rowW("Created"))
rowW("Consignee") = Request.QueryString("Consignee")
rowW("Shipper") = Request.QueryString("Shipper")
rowW("Carrier") = Request.QueryString("Carrier")
rowW("EntryDate") = Request.QueryString("EntryDate")
rowW("Marks") = Request.QueryString("Marks")
rowW("Comments") = Request.QueryString("Comments")
ds.Tables("WAREHOUSE").Rows.Add(rowW)
WarehouseDA.Update(ds, "WAREHOUSE")
-----------------
The following line is supposed to return the RecNo (autonumber) value of the newly inserted record but it just returns an empty value.
Response.Write("RecNo=" & ds.Tables("WAREHOUSE").Rows(0).Item("RecNo"))
It appears that the field values not assigned by me is not visible to dataset. Can I refresh the dataset without losing my pointer to current record so it reflects the changes made in database.
In old ASP , I used to have a recordset and when I update it all the fields from database including the autonumber fields value was available in the recordsets current row.
How can I accomplish this with .net
I use dataset in my asp.net (vb) to update the Datasource but I could not figure out how to read back this autonumber fields value after successfully inserting a record to table.
In other words dataset does not reflect the new value created automatically by database for autonumber field for that specific row after updating the Datasource and thus I have no access to autonumber field which I need to use to update another table.
The code is as follows:
oCommandBuilder = New OleDbCommandBuilder(WarehouseDA)
rowW = ds.Tables("WAREHOUSE").NewRow
Response.Write(rowW("Created"))
rowW("Consignee") = Request.QueryString("Consignee")
rowW("Shipper") = Request.QueryString("Shipper")
rowW("Carrier") = Request.QueryString("Carrier")
rowW("EntryDate") = Request.QueryString("EntryDate")
rowW("Marks") = Request.QueryString("Marks")
rowW("Comments") = Request.QueryString("Comments")
ds.Tables("WAREHOUSE").Rows.Add(rowW)
WarehouseDA.Update(ds, "WAREHOUSE")
-----------------
The following line is supposed to return the RecNo (autonumber) value of the newly inserted record but it just returns an empty value.
Response.Write("RecNo=" & ds.Tables("WAREHOUSE").Rows(0).Item("RecNo"))
It appears that the field values not assigned by me is not visible to dataset. Can I refresh the dataset without losing my pointer to current record so it reflects the changes made in database.
In old ASP , I used to have a recordset and when I update it all the fields from database including the autonumber fields value was available in the recordsets current row.
How can I accomplish this with .net