[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.inetserver.asp.general

parajumpers kodiak damen beige Mzsoife

jybeegix

12/28/2013 5:01:00 PM

<a href=http://www.viniplanete.fr/2013/12/05/canada-gooose-chine/... gooose chine</a> Just yesterday my family went to the local nursery for flower. volatile information to the pitching Was Of intelligence types. <a href=http://www.nilzaboden.se/canada-goose-solaris-parka-c-32_38/billige-canada-goose-solaris-parka-b?r-dam-norge-p-130.htm... Canada Goose Solaris Parka b&#228;r dam p&#229; n&#228;tet</a> Mdoyce <a href=http://www.canadagoosparis.fr/parajumpers-jacka-femme-c-3/>P... Jacka Femme</a>
<a href=http://www.anartisteprod.fr/2013/12/canada-goose-constable-parka-review/... goose constable parka review</a> Nmpubi You can sometimes get a free design from a printing company as a sample design.. <a href=http://www.ateliermosaiquetess.fr/canada-goose-camp-down-hoody-c-39_52/vente-canada-goose-camp-down-hoody-jacinthe-en-ligne-paris-p-180.htm... Canada Goose Camp Down Hoody Jacinthe En Ligne Paris</a>
<a href=http://www.bengansror.se/officiella-parajumpers-new-arches-w-jacka-svarta-kvinnor-webbutik>... Parajumpers New Arches-W jacka svarta kvinnor webbutik</a> 1936378753
6 Answers

TheSQLGuru

11/30/2007 2:49:00 PM

0

I seem to recall a client trying to do that recently (using ADO classic) and
it not working. Perhaps they missed the semicolon. I will recheck their
attempts and see if that does it.

One additional question since I am not an ADO guru. Does the Select
Scope_identity() not return a single-column single-row result set, which the
executescalar isn't expecting?

--
Kevin G. Boles
TheSQLGuru
Indicium Resources, Inc.


"Kerry Moorman" <KerryMoorman@discussions.microsoft.com> wrote in message
news:D12AFECB-DC31-4CE3-A2A2-14F3AB3CD95D@microsoft.com...
> Kevin,
>
> Sure you can, like this:
>
> cmd.CommandText = "Insert Into Students (StudentName, Test1, Test2) Values
> (@StudentName, @Test1, @Test2); Select Scope_Identity()"
>
> Then:
>
> ID = cmd.ExecuteScalar
>
> Kerry Moorman
>
>
> "TheSQLGuru" wrote:
>
>> This method obviously requires using stored procs (which is almost always
>> a
>> good idea for a bunch of reasons). If you are using ADO/ADONET you are
>> in a
>> bit of a bind I think. IIRC you can't issue an insert statement and get
>> a
>> select back out in a single Execute... type command.
>>
>> --
>> Kevin G. Boles
>> TheSQLGuru
>> Indicium Resources, Inc.
>>
>>
>> "Ibrahim Shameeque" <IbrahimShameeque@discussions.microsoft.com> wrote in
>> message news:88277D10-9F15-42C3-BA0B-D18E4377E160@microsoft.com...
>> > Hi
>> > You can use the output parameter of the stored procedure and return the
>> > value that is being inserted. If you are using identity column then you
>> > can
>> > use @@IDENTITY to return the last inserted indentity value.
>> > --
>> > ---------------------------
>> > Thanks,
>> > Ibrahim
>> >
>> > Software Consultant - Web Development, GB
>> >
>> >
>> > "Nathan Sokalski" wrote:
>> >
>> >> I am using ASP.NET 2.0 to add records to a database table in an SQL
>> >> Server
>> >> database. The id field is automatically created when a record is
>> >> added,
>> >> and
>> >> I would like to be able to know what value was assigned to the id
>> >> field
>> >> for
>> >> use in my ASP.NET application. Is there a way to find out what value
>> >> was
>> >> assigned to the record at the same time I create the record (in
>> >> otherwords,
>> >> I do not want to use a SELECT statement)? Thanks.
>> >>
>> >> --
>> >> Nathan Sokalski
>> >> njsokalski@hotmail.com
>> >> http://www.nathansok...
>> >>
>> >>
>> >>
>>
>>
>>


Miha Markic

11/30/2007 4:07:00 PM

0

Right.
BTW one should always use Scope_Identity() and not @@Identity as posted by
Ibrahim.

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_...

"Kerry Moorman" <KerryMoorman@discussions.microsoft.com> wrote in message
news:D12AFECB-DC31-4CE3-A2A2-14F3AB3CD95D@microsoft.com...
> Kevin,
>
> Sure you can, like this:
>
> cmd.CommandText = "Insert Into Students (StudentName, Test1, Test2) Values
> (@StudentName, @Test1, @Test2); Select Scope_Identity()"

TheSQLGuru

11/30/2007 4:25:00 PM

0

I just checked back with the developer that had the issue. He swears that
using VB6 and ADO classic your example fails. Were you using ADOc or
ADO.NET?

--
Kevin G. Boles
TheSQLGuru
Indicium Resources, Inc.


"Kerry Moorman" <KerryMoorman@discussions.microsoft.com> wrote in message
news:6AD6FF28-692A-4DFA-9BCB-7D8E9A2302C1@microsoft.com...
> Kevin,
>
> ExecuteScalar returns the first column of the first row in the result set
> returned by the query.
>
> Kerry Moorman
>
>
> "TheSQLGuru" wrote:
>
>>
>> One additional question since I am not an ADO guru. Does the Select
>> Scope_identity() not return a single-column single-row result set, which
>> the
>> executescalar isn't expecting?
>>
>> --
>> Kevin G. Boles
>> TheSQLGuru
>> Indicium Resources, Inc.
>>
>


TheSQLGuru

12/2/2007 1:43:00 AM

0

Recalling that I am NOT an ADO guru - despite having a copy of Vaughn's
book - I tried to get this to work. First I found that in ADO 2.8 there is
no ExecuteScalar (at least not that I found). So I tried it using a
recordset, with the following code:

Private Sub Command1_Click()

'here is the table def I used
'use northwind
'go
'create table c (c int identity, b char(1))

' connection, command, and recordset variables
Dim Cnxn As Connection
Dim cmdChange As Command
Dim rs As Recordset

' Open connection
Set Cnxn = New Connection
Cnxn.Open "Provider='sqloledb';Data Source='(local)';Initial
Catalog='Northwind';Integrated Security='SSPI';"

' Create command object
Set cmdChange = New Command
Set cmdChange.ActiveConnection = Cnxn
cmdChange.CommandText = "insert c (b) values ('A'); select
scope_identity() as a"

Set rs = cmdChange.Execute()

rs.MoveFirst

Do While Not rs.EOF
id = rs.Fields(0)
Loop

Cnxn.Close
Set rstTitles = Nothing
Set Cnxn = Nothing
Exit Sub

End Sub


I get the following message when I step on rs.MoveFirst - Operation is not
allowed when the object is closed.

Perhaps it can be done using a parameter with the command execute?

--
Kevin G. Boles
TheSQLGuru
Indicium Resources, Inc.


"William Vaughn" <billvaNoSPAM@betav.com> wrote in message
news:60D10EA7-B3DC-4799-B203-DBD9D6010E5D@microsoft.com...
> The approach in VB6 is virtually identical.
>
> --
> ____________________________________
> William (Bill) Vaughn
> Author, Mentor, Consultant, Dad, Grandpa
> Microsoft MVP
> INETA Speaker
> www.betav.com
> www.betav.com/blog/billva
> Please reply only to the newsgroup so that others can benefit.
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> __________________________________
> Visit www.hitchhikerguides.net to get more information on my latest book:
> Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
> and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
> -----------------------------------------------------------------------------------------------------------------------
>
> "Kerry Moorman" <KerryMoorman@discussions.microsoft.com> wrote in message
> news:166C19B7-E834-4810-AD56-7B6DB65E0FDC@microsoft.com...
>> Kevin,
>>
>> My example was using ADO.Net.
>>
>> Kerry Moorman
>>
>>
>> "TheSQLGuru" wrote:
>>
>>> I just checked back with the developer that had the issue. He swears
>>> that
>>> using VB6 and ADO classic your example fails. Were you using ADOc or
>>> ADO.NET?
>>>
>>> --
>>> Kevin G. Boles
>>> TheSQLGuru
>>> Indicium Resources, Inc.
>>>
>>>
>>> "Kerry Moorman" <KerryMoorman@discussions.microsoft.com> wrote in
>>> message
>>> news:6AD6FF28-692A-4DFA-9BCB-7D8E9A2302C1@microsoft.com...
>>> > Kevin,
>>> >
>>> > ExecuteScalar returns the first column of the first row in the result
>>> > set
>>> > returned by the query.
>>> >
>>> > Kerry Moorman
>>> >
>>> >
>>> > "TheSQLGuru" wrote:
>>> >
>>> >>
>>> >> One additional question since I am not an ADO guru. Does the Select
>>> >> Scope_identity() not return a single-column single-row result set,
>>> >> which
>>> >> the
>>> >> executescalar isn't expecting?
>>> >>
>>> >> --
>>> >> Kevin G. Boles
>>> >> TheSQLGuru
>>> >> Indicium Resources, Inc.
>>> >>
>>> >
>>>
>>>
>>>
>


Tibor Karaszi

12/2/2007 8:11:00 AM

0

Classic ADO treats the "rows affected" message as a recordset. Try adding SET NOCOUNT ON before your
INSERT statement to suppress this.

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/d...
http://sqlblog.com/blogs/tib...


"TheSQLGuru" <kgboles@earthlink.net> wrote in message news:13l43clknmi8j2f@corp.supernews.com...
> Recalling that I am NOT an ADO guru - despite having a copy of Vaughn's book - I tried to get this
> to work. First I found that in ADO 2.8 there is no ExecuteScalar (at least not that I found). So
> I tried it using a recordset, with the following code:
>
> Private Sub Command1_Click()
>
> 'here is the table def I used
> 'use northwind
> 'go
> 'create table c (c int identity, b char(1))
>
> ' connection, command, and recordset variables
> Dim Cnxn As Connection
> Dim cmdChange As Command
> Dim rs As Recordset
>
> ' Open connection
> Set Cnxn = New Connection
> Cnxn.Open "Provider='sqloledb';Data Source='(local)';Initial Catalog='Northwind';Integrated
> Security='SSPI';"
>
> ' Create command object
> Set cmdChange = New Command
> Set cmdChange.ActiveConnection = Cnxn
> cmdChange.CommandText = "insert c (b) values ('A'); select scope_identity() as a"
>
> Set rs = cmdChange.Execute()
>
> rs.MoveFirst
>
> Do While Not rs.EOF
> id = rs.Fields(0)
> Loop
>
> Cnxn.Close
> Set rstTitles = Nothing
> Set Cnxn = Nothing
> Exit Sub
>
> End Sub
>
>
> I get the following message when I step on rs.MoveFirst - Operation is not allowed when the object
> is closed.
>
> Perhaps it can be done using a parameter with the command execute?
>
> --
> Kevin G. Boles
> TheSQLGuru
> Indicium Resources, Inc.
>
>
> "William Vaughn" <billvaNoSPAM@betav.com> wrote in message
> news:60D10EA7-B3DC-4799-B203-DBD9D6010E5D@microsoft.com...
>> The approach in VB6 is virtually identical.
>>
>> --
>> ____________________________________
>> William (Bill) Vaughn
>> Author, Mentor, Consultant, Dad, Grandpa
>> Microsoft MVP
>> INETA Speaker
>> www.betav.com
>> www.betav.com/blog/billva
>> Please reply only to the newsgroup so that others can benefit.
>> This posting is provided "AS IS" with no warranties, and confers no rights.
>> __________________________________
>> Visit www.hitchhikerguides.net to get more information on my latest book:
>> Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
>> and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
>> -----------------------------------------------------------------------------------------------------------------------
>>
>> "Kerry Moorman" <KerryMoorman@discussions.microsoft.com> wrote in message
>> news:166C19B7-E834-4810-AD56-7B6DB65E0FDC@microsoft.com...
>>> Kevin,
>>>
>>> My example was using ADO.Net.
>>>
>>> Kerry Moorman
>>>
>>>
>>> "TheSQLGuru" wrote:
>>>
>>>> I just checked back with the developer that had the issue. He swears that
>>>> using VB6 and ADO classic your example fails. Were you using ADOc or
>>>> ADO.NET?
>>>>
>>>> --
>>>> Kevin G. Boles
>>>> TheSQLGuru
>>>> Indicium Resources, Inc.
>>>>
>>>>
>>>> "Kerry Moorman" <KerryMoorman@discussions.microsoft.com> wrote in message
>>>> news:6AD6FF28-692A-4DFA-9BCB-7D8E9A2302C1@microsoft.com...
>>>> > Kevin,
>>>> >
>>>> > ExecuteScalar returns the first column of the first row in the result set
>>>> > returned by the query.
>>>> >
>>>> > Kerry Moorman
>>>> >
>>>> >
>>>> > "TheSQLGuru" wrote:
>>>> >
>>>> >>
>>>> >> One additional question since I am not an ADO guru. Does the Select
>>>> >> Scope_identity() not return a single-column single-row result set, which
>>>> >> the
>>>> >> executescalar isn't expecting?
>>>> >>
>>>> >> --
>>>> >> Kevin G. Boles
>>>> >> TheSQLGuru
>>>> >> Indicium Resources, Inc.
>>>> >>
>>>> >
>>>>
>>>>
>>>>
>>
>
>

TheSQLGuru

12/3/2007 2:52:00 AM

0

THANKS Tibor - that was the trick I was looking for!

--
Kevin G. Boles
TheSQLGuru
Indicium Resources, Inc.


"Tibor Karaszi" <tibor_please.no.email_karaszi@hotmail.nomail.com> wrote in
message news:36DE8404-60E2-4AC8-B904-BFFD38821E6C@microsoft.com...
> Classic ADO treats the "rows affected" message as a recordset. Try adding
> SET NOCOUNT ON before your INSERT statement to suppress this.
>
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/d...
> http://sqlblog.com/blogs/tib...
>
>
> "TheSQLGuru" <kgboles@earthlink.net> wrote in message
> news:13l43clknmi8j2f@corp.supernews.com...
>> Recalling that I am NOT an ADO guru - despite having a copy of Vaughn's
>> book - I tried to get this to work. First I found that in ADO 2.8 there
>> is no ExecuteScalar (at least not that I found). So I tried it using a
>> recordset, with the following code:
>>
>> Private Sub Command1_Click()
>>
>> 'here is the table def I used
>> 'use northwind
>> 'go
>> 'create table c (c int identity, b char(1))
>>
>> ' connection, command, and recordset variables
>> Dim Cnxn As Connection
>> Dim cmdChange As Command
>> Dim rs As Recordset
>>
>> ' Open connection
>> Set Cnxn = New Connection
>> Cnxn.Open "Provider='sqloledb';Data Source='(local)';Initial
>> Catalog='Northwind';Integrated Security='SSPI';"
>>
>> ' Create command object
>> Set cmdChange = New Command
>> Set cmdChange.ActiveConnection = Cnxn
>> cmdChange.CommandText = "insert c (b) values ('A'); select
>> scope_identity() as a"
>>
>> Set rs = cmdChange.Execute()
>>
>> rs.MoveFirst
>>
>> Do While Not rs.EOF
>> id = rs.Fields(0)
>> Loop
>>
>> Cnxn.Close
>> Set rstTitles = Nothing
>> Set Cnxn = Nothing
>> Exit Sub
>>
>> End Sub
>>
>>
>> I get the following message when I step on rs.MoveFirst - Operation is
>> not allowed when the object is closed.
>>
>> Perhaps it can be done using a parameter with the command execute?
>>
>> --
>> Kevin G. Boles
>> TheSQLGuru
>> Indicium Resources, Inc.
>>
>>
>> "William Vaughn" <billvaNoSPAM@betav.com> wrote in message
>> news:60D10EA7-B3DC-4799-B203-DBD9D6010E5D@microsoft.com...
>>> The approach in VB6 is virtually identical.
>>>
>>> --
>>> ____________________________________
>>> William (Bill) Vaughn
>>> Author, Mentor, Consultant, Dad, Grandpa
>>> Microsoft MVP
>>> INETA Speaker
>>> www.betav.com
>>> www.betav.com/blog/billva
>>> Please reply only to the newsgroup so that others can benefit.
>>> This posting is provided "AS IS" with no warranties, and confers no
>>> rights.
>>> __________________________________
>>> Visit www.hitchhikerguides.net to get more information on my latest
>>> book:
>>> Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
>>> and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
>>> -----------------------------------------------------------------------------------------------------------------------
>>>
>>> "Kerry Moorman" <KerryMoorman@discussions.microsoft.com> wrote in
>>> message news:166C19B7-E834-4810-AD56-7B6DB65E0FDC@microsoft.com...
>>>> Kevin,
>>>>
>>>> My example was using ADO.Net.
>>>>
>>>> Kerry Moorman
>>>>
>>>>
>>>> "TheSQLGuru" wrote:
>>>>
>>>>> I just checked back with the developer that had the issue. He swears
>>>>> that
>>>>> using VB6 and ADO classic your example fails. Were you using ADOc or
>>>>> ADO.NET?
>>>>>
>>>>> --
>>>>> Kevin G. Boles
>>>>> TheSQLGuru
>>>>> Indicium Resources, Inc.
>>>>>
>>>>>
>>>>> "Kerry Moorman" <KerryMoorman@discussions.microsoft.com> wrote in
>>>>> message
>>>>> news:6AD6FF28-692A-4DFA-9BCB-7D8E9A2302C1@microsoft.com...
>>>>> > Kevin,
>>>>> >
>>>>> > ExecuteScalar returns the first column of the first row in the
>>>>> > result set
>>>>> > returned by the query.
>>>>> >
>>>>> > Kerry Moorman
>>>>> >
>>>>> >
>>>>> > "TheSQLGuru" wrote:
>>>>> >
>>>>> >>
>>>>> >> One additional question since I am not an ADO guru. Does the
>>>>> >> Select
>>>>> >> Scope_identity() not return a single-column single-row result set,
>>>>> >> which
>>>>> >> the
>>>>> >> executescalar isn't expecting?
>>>>> >>
>>>>> >> --
>>>>> >> Kevin G. Boles
>>>>> >> TheSQLGuru
>>>>> >> Indicium Resources, Inc.
>>>>> >>
>>>>> >
>>>>>
>>>>>
>>>>>
>>>
>>
>>
>