Re: I Have No Identity

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

From: Miha Markic [MVP C#] (miha)
Date: 02/20/04


Date: Fri, 20 Feb 2004 11:07:46 +0100

Hi Jerry,

Scope_identity() is the right one.
About your problem: what do you mean that you get the whole table?
What is your scenario?

-- 
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com
"Jerry Camel" <rlrcstr@msn.com> wrote in message
news:%23taobN09DHA.1816@TK2MSFTNGP12.phx.gbl...
> This has been addressed several times and I've read several articles and
> posts and I still can't get this to work.  (This is VB .NET)
>
> My understanding is that if I append a select statement to my
DataAdapter's
> Insert statement that I should be able to get an updated resultset.  I've
> got this:
>
> INSERT INTO dbo.FD_Files (FileName, ExpireTime, PostedBy, HashName,
> FileSize, Description) VALUES (@FileName, @ExpireTime, @PostedBy,
@HashName,
> @FileSize, @Description); SELECT FileID, FileName, ExpireTime, PostedBy,
> HashName, FileSize, Description FROM dbo.FD_Files WHERE FileID =
@@IDENTITY
>
> I've also tried using SCOPE_IDENTITY() - reagrdless, I always get the
whole
> table returned.
>
> I need to know the identity of the record I just added and I keep getting
a
> whole table.  It's making me crazy.
>
> I've even tried setting the adapter's select command to SELECT FileID from
> FD_Files WHERE FileID = SCOPE_IDENTITY() and re-filling the dataset.  I
get
> the whole damned table.  Why!!!!????
>
> What am I missing?  I've tried using the built in wizard which comes up
with
> an insert statement just like the one above and I still end up with the
> whole table after I update.
>
> Can anyone shed some light on this?  Thanks.
>
> Jerry
>
>


Relevant Pages

  • I Have No Identity
    ... INSERT INTO dbo.FD_Files (FileName, ExpireTime, PostedBy, HashName, ... HashName, FileSize, Description FROM dbo.FD_Files WHERE FileID = @@IDENTITY ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: I Have No Identity
    ... Dim cmdFiles As New SqlCommand ... Dim daFiles As New SqlDataAdapter("SELECT FileID, FileName, ExpireTime, ... PostedBy, HashName, FileSize, Description FROM FD_Files", sqlCnxn) ...
    (microsoft.public.dotnet.framework.adonet)