Re: Retrieving Record after INSERT INTO statement

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Val Mazur (group51a_at_hotmail.com)
Date: 03/28/04


Date: Sun, 28 Mar 2004 16:47:53 -0500

Hi,

In case of the DataSet, it is suppose to populate identity values for the
inserted records.
In case of the regular SQL statement, you need to get it back. Check next
KBs about it

http://support.microsoft.com/default.aspx?scid=kb;en-us;320141&Product=adonet

http://support.microsoft.com/default.aspx?scid=kb;en-us;815629&Product=adonet

-- 
Val Mazur
Microsoft MVP
"Joshua Ellul" <jellul@onvol.net> wrote in message 
news:u3pGCtOFEHA.3096@TK2MSFTNGP11.phx.gbl...
> Once I call the update will the record in the database and the instance in
> the datatable be synchronised? I.e. I have an Autonumber field in which 
> the
> database engine fills in the autonumber field and not my program, will my
> program upon update have the value of the Autonumber field?
>
> Josh
>
> "Val Mazur" <group51a@hotmail.com> wrote in message
> news:uomKAiCFEHA.2868@TK2MSFTNGP12.phx.gbl...
>> Hi Joshua,
>>
>> If you execute action query, like INSERT, then there is no way to get 
>> this
>> record back other than to use another SELECT statement. If you would like
> to
>> keep information on a client side as well, then add record to the
> DataTable
>> and then call Update method of the dataAdapter to insert record from the
>> DataTable into actual table in a database. Otherwise you would need to
> make
>> two calls - INSERT and SELECT
>>
>> --
>> Val Mazur
>> Microsoft MVP
>>
>>
>> "Joshua Ellul" <jellul@onvol.net> wrote in message
>> news:%238iflBBFEHA.1456@TK2MSFTNGP09.phx.gbl...
>> > Hi There,
>> >
>> > I am using an OleDb.OleDbCommand to insert a new record using the
>> > ExecuteNonQuery method with an SQL "INSERT INTO" statement.  Is it
>> > possible
>> > to somehow retrieve the record/s inserted without having to perform an
>> > additional SQL statement?
>> >
>> > If not, is there a different method to insert data which automatically
>> > returns the record inserted?
>> >
>> > Best Regards,
>> >
>> > Joshua
>> >
>> >
>>
>>
>
> 


Relevant Pages

  • Re: ADO data control
    ... Another way to test your query would be to try ... instinctively think that the database is probably not normalized. ... written on the topic of normalization, and one you might like is "Database ... Then the SQL statement and the existing WHERE and ORDER BY calculations ...
    (microsoft.public.vb.controls)
  • RE: FK Constraint Raised for no reason I can find?
    ... the constraints won't be copied to the destination database. ... But you could modify the sql statement for creating the table in the ... SQL Statement window above. ... Microsoft Online Community Support ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • RE: FK Constraint Raised for no reason I can find?
    ... the constraints won't be copied to the destination database. ... But you could modify the sql statement for creating the table in the ... SQL Statement window above. ... Microsoft Online Community Support ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: Retrieving Record after INSERT INTO statement
    ... database engine fills in the autonumber field and not my program, ... > and then call Update method of the dataAdapter to insert record from the ... >> additional SQL statement? ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Access having run time errors while selecting from odbc linked table
    ... Ok Frank, here ya go: ... Date and Load are variables that are collected by an input box so the sql statement can be dynamic in nature. ... >> Dim con As Object ... >> The exact same code sequence is used in the Database to select items from ...
    (microsoft.public.data.odbc)