472,791 Members | 2,165 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,791 software developers and data experts.

DAAB output pararmeters

Hello,

I'm using ASP.Net 2.0 and the Jan 2006 Enterprise Library.

What I'm doing is passing an ArrayList into a stroed procedure to do an
Insert. Here's some code:

Dim params as New ArrarList
params.Add("first parameter value")
params.Add("second parameter value")
etc.

db.ExecuteNonQuery(transaction, "sproc_Insert", params.ToArray)
tansaction.Commit()

Obviously some code is missing, which doesn't matter because the insert
works. The problem I'm not sure how to get around is how can I get the ID of
the inserted record out of hte stored procedure using this same method or is
there a way to add something to what I'm doing to get the @@indentity from
the SPROC.

Any suggestions are welcomed.

Thanks
Clint Pidlubny
Nov 9 '06 #1
4 3348
Something along these lines.
db.AddOutParameter( "@numberRowsAffected", DbType.Int32, 0)

Dim rowsAffected As Int32

rowsAffected = db.ExecuteNonQuery()

' Row of data is captured via output parameters
Dim results As String =
String.Format(CultureInfo.CurrentCulture, "{0}", db.GetParameterValue(
"@numberRowsAffected"))
"@numberRowsAffected is if you declare an output parameter for the stored
procedure and populate it

rowsAffected works also, BUT doesn't work against select queries.

I usually include the output parameter and populate that way, if I want
IDENTITY or any other value.


"Clint Pidlubny" <Clint Pi******@discussions.microsoft.comwrote in message
news:82**********************************@microsof t.com...
Hello,

I'm using ASP.Net 2.0 and the Jan 2006 Enterprise Library.

What I'm doing is passing an ArrayList into a stroed procedure to do an
Insert. Here's some code:

Dim params as New ArrarList
params.Add("first parameter value")
params.Add("second parameter value")
etc.

db.ExecuteNonQuery(transaction, "sproc_Insert", params.ToArray)
tansaction.Commit()

Obviously some code is missing, which doesn't matter because the insert
works. The problem I'm not sure how to get around is how can I get the ID
of
the inserted record out of hte stored procedure using this same method or
is
there a way to add something to what I'm doing to get the @@indentity from
the SPROC.

Any suggestions are welcomed.

Thanks
Clint Pidlubny

Nov 9 '06 #2
Thanks for trying but that isn't what I'm looking for.

I'm only passing an ArrayList and letting SQL Server match up the
parameters, so I'm not specifically stating the parameters. I actually don't
have a problem getting the # of rows affected, but what I'm not sure about is
how to pass the @@identity when I'm only passing an ArrayList for the
parameters.

It might not be possible, but I thought I'd check.

Thanks anyways.

Clint

"sloan" wrote:
Something along these lines.
db.AddOutParameter( "@numberRowsAffected", DbType.Int32, 0)

Dim rowsAffected As Int32

rowsAffected = db.ExecuteNonQuery()

' Row of data is captured via output parameters
Dim results As String =
String.Format(CultureInfo.CurrentCulture, "{0}", db.GetParameterValue(
"@numberRowsAffected"))
"@numberRowsAffected is if you declare an output parameter for the stored
procedure and populate it

rowsAffected works also, BUT doesn't work against select queries.

I usually include the output parameter and populate that way, if I want
IDENTITY or any other value.


"Clint Pidlubny" <Clint Pi******@discussions.microsoft.comwrote in message
news:82**********************************@microsof t.com...
Hello,

I'm using ASP.Net 2.0 and the Jan 2006 Enterprise Library.

What I'm doing is passing an ArrayList into a stroed procedure to do an
Insert. Here's some code:

Dim params as New ArrarList
params.Add("first parameter value")
params.Add("second parameter value")
etc.

db.ExecuteNonQuery(transaction, "sproc_Insert", params.ToArray)
tansaction.Commit()

Obviously some code is missing, which doesn't matter because the insert
works. The problem I'm not sure how to get around is how can I get the ID
of
the inserted record out of hte stored procedure using this same method or
is
there a way to add something to what I'm doing to get the @@indentity from
the SPROC.

Any suggestions are welcomed.

Thanks
Clint Pidlubny


Nov 9 '06 #3
You'll have to pass it in some parameter form. You'll need to either use the
return result parameter (if the identity is an integer) or another parameter
defined as an output.

Also, don't use @@IDENTITY. What you want is SCOPE_IDENTITY(). Using
@@Identity returns the last insert record, anywhere. If another insert
happens at close to the same time SQL Server will grab that one. Using
SCOPE_IDENTITY() ensures that the identity being returned is the last one
that was added within the scope of the current operation, such as the
current stored procedure
--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"Clint Pidlubny" <Cl***********@discussions.microsoft.comwrote in message
news:D8**********************************@microsof t.com...
Thanks for trying but that isn't what I'm looking for.

I'm only passing an ArrayList and letting SQL Server match up the
parameters, so I'm not specifically stating the parameters. I actually
don't
have a problem getting the # of rows affected, but what I'm not sure about
is
how to pass the @@identity when I'm only passing an ArrayList for the
parameters.

It might not be possible, but I thought I'd check.

Thanks anyways.

Clint

"sloan" wrote:
>Something along these lines.
db.AddOutParameter( "@numberRowsAffected", DbType.Int32,
0)

Dim rowsAffected As Int32

rowsAffected = db.ExecuteNonQuery()

' Row of data is captured via output parameters
Dim results As String =
String.Format(CultureInfo.CurrentCulture, "{0}", db.GetParameterValue(
"@numberRowsAffected"))
"@numberRowsAffected is if you declare an output parameter for the stored
procedure and populate it

rowsAffected works also, BUT doesn't work against select queries.

I usually include the output parameter and populate that way, if I want
IDENTITY or any other value.


"Clint Pidlubny" <Clint Pi******@discussions.microsoft.comwrote in
message
news:82**********************************@microso ft.com...
Hello,

I'm using ASP.Net 2.0 and the Jan 2006 Enterprise Library.

What I'm doing is passing an ArrayList into a stroed procedure to do an
Insert. Here's some code:

Dim params as New ArrarList
params.Add("first parameter value")
params.Add("second parameter value")
etc.

db.ExecuteNonQuery(transaction, "sproc_Insert", params.ToArray)
tansaction.Commit()

Obviously some code is missing, which doesn't matter because the insert
works. The problem I'm not sure how to get around is how can I get the
ID
of
the inserted record out of hte stored procedure using this same method
or
is
there a way to add something to what I'm doing to get the @@indentity
from
the SPROC.

Any suggestions are welcomed.

Thanks
Clint Pidlubny



Nov 9 '06 #4
Thanks Mark. I didn't know that about @@Identity. Have you ever tried passing
a parameter through an ArrayList, like I describe, or do I have to take a
different approach if I want to grab an identity?

Clint

"Mark Fitzpatrick" wrote:
You'll have to pass it in some parameter form. You'll need to either use the
return result parameter (if the identity is an integer) or another parameter
defined as an output.
Also, don't use @@IDENTITY. What you want is SCOPE_IDENTITY(). Using
@@Identity returns the last insert record, anywhere. If another insert
happens at close to the same time SQL Server will grab that one. Using
SCOPE_IDENTITY() ensures that the identity being returned is the last one
that was added within the scope of the current operation, such as the
current stored procedure
--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006
Nov 13 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: sedefo | last post by:
I ran into this Microsoft Patterns & Practices Enterprise Library while i was researching how i can write a database independent data access layer. In my company we already use Data Access...
1
by: Özgür Aytekin | last post by:
Hello NG Is DAAB 3.1 the offical replacement of Microsoft Data Access Application Block 2.0? DAAB 3.1 download:...
3
by: veera sekhar kota | last post by:
hi, im seriously looking for right answer .... We are developing windows application in c#. I implemented DAAB(Data Access Application Block) 2.0 in our application. One of the senior asked...
0
by: veera sekhar kota | last post by:
im seriously looking for right answer .... We are developing windows application in c#. I implemented DAAB(Data Access Application Block) 2.0 in our application. One of the senior asked me to...
0
by: veera sekhar kota | last post by:
im seriously looking for right answer .... We are developing windows application in c#. I implemented DAAB(Data Access Application Block) 2.0 in our application. One of the senior asked me to...
7
by: Alec MacLean | last post by:
Hi all, I'm trying to deploy an ASP.NET (1.1) app to our production webserver, but having problems with the DAAB (from Ent Lib June 2005). As you might guess, it works just fine and dandy on my...
8
by: Alec MacLean | last post by:
Hi, I'm using the DAAB Ent Lib (Jan 2006) for .NET 2.0, with VS 2005 Pro. My project is a Web app project (using the WAP add in). Background: I'm creating a survey system for our company, for...
5
by: | last post by:
Hi, I'm having difficulty connecting my .NET web app to my SQL2000 database via the DAAB. I'm using VS2003 with .NET 1.1. I'm currently trying names such as Initial Catalog, Data Source, User...
0
by: dobee | last post by:
Hi all, currently via ado.net, to read an external file we can do this: DataSet myDS = new DataSet(); myDS.ReadXml("input.xml", XmlReadMode.ReadSchema); but i cant seem to find any equivalent...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.