VS.Net not returning identity values

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Rob Oldfield (rob_at_oldfield100_wow_freeserve_yikes_co_incredible!_uk)
Date: 06/28/04


Date: Mon, 28 Jun 2004 19:26:28 +0100


A strange situation that I've just sorted out, but I'm looking for an
explanation...

I have a dataset that is pulling information back out of an SQL 2K server.
I'm setting the PK values of the datatable to negative values when using it
in my code and then expecting them to be updated to the correct ID values
when I run an update.

That works fine if the SQL statement for the dataadapter is a
straightforward select, but if I complicate things a little by introducing a
criteria on a parent table (i.e. I don't want all the subtable rows, just
those where a condition is true on the parent table) then the insert and
update commands generated by VS.Net (2003) don't automatically include the
select command to retrieve the newly inserted ID values. I've just gone in
and manually added those select commands but my question is...

Why doesn't VS do it for me? Am I missing something?



Relevant Pages

  • Re: How I can sysnchronize changes in DataTable with my Database?
    ... Do you mean whether ADO .NET can generate the commands for you? ... Does your question actually mean "I don't want to bother with all that SQL. ... >>> DataTableMapping tableMapping) ... >>> foreach(DataRow myDataRow in myDataTable.Rows) ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Ok, call me silly...
    ... out it will also use substantially fewer resources than Informix too. ... I in fact see SQLite matching Oracle and DB2 in load speed. ... SQL> CREATE TABLE parent ( ... SQL> CREATE TABLE child AS ...
    (comp.databases.informix)
  • Re: Post Revised: A Desperate Plea for Help
    ... I got your point that generated sql is often inadequate. ... generated commands may be inadequate" but "Use the dataadapter's Update ... That's why my advice was to call the data adapter's Update method. ... But the bottom line here is that you need to create the SQL Statements ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: DataGrid problem.
    ... (and SQL) ... as well as the Insert and Update commands? ... > dataAdapters sql commands parameters Value field, ... >> to the grid, it is automatically assigned a NULL value when a new row is ...
    (microsoft.public.dotnet.framework.windowsforms.databinding)
  • Re: Mixing select and print statements using DBI, DBD::Sybase
    ... Isql does not have its own commands. ... in the sql batch has the print executing later. ...
    (perl.dbi.users)