Search:
Namespaces
Discussions
.NET v1.1
Feedback
HELP: Returning multiple values from a function
Messages
Related Types
This message was discovered on
ASPFriends.com 'aspngvb' list
.
Jason Hick
-- Moved from [aspngfreeforall] to [aspngvb] by Tim Musschoot <
Click here to reveal e-mail address
> --
Hi,
This might be a really basic question, so apologies in advance!!
I've got a function that needs to return 3 values (Outputs from a stored
procedure), but I can only seem to retrieve 1 of the values on my ASP page.
Is it possible to do this using my code below? I've managed to return all 3
values as a string...
Return CInt(sqlParam30.Value) & "|" & CInt(sqlParam31.Value) & "|" &
CInt(sqlParam32.Value)
....but I don't really want to have to manipulate the string on the
receiving page.
Here's my code:
code extract -----------------------
Dim sqlParam30 As
SqlParameter
= New
SqlParameter
("@intCustomerID",
SqlDbType
.Int, 4)
sqlParam30.Direction =
ParameterDirection
.Output
myCommand.Parameters.Add(sqlParam30)
Dim sqlParam31 As
SqlParameter
= New
SqlParameter
("@intInvoiceID",
SqlDbType
.Int, 4)
sqlParam31.Direction =
ParameterDirection
.Output
myCommand.Parameters.Add(sqlParam31)
Dim sqlParam32 As
SqlParameter
= New
SqlParameter
("@intDeliveryID",
SqlDbType
.Int, 4)
sqlParam32.Direction =
ParameterDirection
.Output
myCommand.Parameters.Add(sqlParam32)
'## Open the connection and execute the Command
MyConnection.Open()
myCommand.ExecuteNonQuery()
MyConnection.Close()
'## Return the ID's
Return (sqlParam30.Value)
Return (sqlParam31.Value)
Return (sqlParam32.Value)
end extract ---------------------------
Regards,
Jason
Reply to this message...
isaacs@journalinteractive.com (Scott Isaacs)
one solution is to pass in the variables byRef and set them in the
function
e.g.
dim int1 as int32
dim int2 as int32
myFunc(int1, int2)
function myFunc(byRef parm1 as int32, byRef parm2 as int32)
parm1 = 3
parm2 = 7
end function
-----Original Message-----
From: Jason Hick [mailto:
Click here to reveal e-mail address
]
Sent: Tuesday, July 02, 2002 4:06 AM
To: aspngvb
Subject: [aspngvb] HELP: Returning multiple values from a function
-- Moved from [aspngfreeforall] to [aspngvb] by Tim Musschoot
<
Click here to reveal e-mail address
> --
Hi,
This might be a really basic question, so apologies in advance!!
I've got a function that needs to return 3 values (Outputs from a stored
procedure), but I can only seem to retrieve 1 of the values on my ASP
page.
Is it possible to do this using my code below? I've managed to return
all 3
values as a string...
Return CInt(sqlParam30.Value) & "|" & CInt(sqlParam31.Value) & "|" &
CInt(sqlParam32.Value)
....but I don't really want to have to manipulate the string on the
receiving page.
Here's my code:
code extract -----------------------
Dim sqlParam30 As
SqlParameter
= New
SqlParameter
("@intCustomerID",
SqlDbType
.Int, 4)
sqlParam30.Direction =
ParameterDirection
.Output
myCommand.Parameters.Add(sqlParam30)
Dim sqlParam31 As
SqlParameter
= New
SqlParameter
("@intInvoiceID",
SqlDbType
.Int, 4)
sqlParam31.Direction =
ParameterDirection
.Output
myCommand.Parameters.Add(sqlParam31)
Dim sqlParam32 As
SqlParameter
= New
SqlParameter
("@intDeliveryID",
SqlDbType
.Int, 4)
sqlParam32.Direction =
ParameterDirection
.Output
myCommand.Parameters.Add(sqlParam32)
'## Open the connection and execute the Command
MyConnection.Open()
myCommand.ExecuteNonQuery()
MyConnection.Close()
'## Return the ID's
Return (sqlParam30.Value)
Return (sqlParam31.Value)
Return (sqlParam32.Value)
end extract ---------------------------
Regards,
Jason
| [aspngvb] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.asplists.com/asplists/aspngvb.asp
= JOIN/QUIT
Reply to this message...
Guillermo E. Rivero
You can create a class with 3 fields, 1 for each value, in that way you
can handle each value...
-----Original Message-----
From: Jason Hick [mailto:
Click here to reveal e-mail address
]=20
Sent: Martes, 02 de Julio de 2002 05:06 a.m.
To: aspngvb
Subject: [aspngvb] HELP: Returning multiple values from a function
-- Moved from [aspngfreeforall] to [aspngvb] by Tim Musschoot
<
Click here to reveal e-mail address
> --
Hi,
This might be a really basic question, so apologies in advance!!
I've got a function that needs to return 3 values (Outputs from a stored
procedure), but I can only seem to retrieve 1 of the values on my ASP
page. Is it possible to do this using my code below? I've managed to
return all 3 values as a string...
Return CInt(sqlParam30.Value) & "|" & CInt(sqlParam31.Value) & "|" &
CInt(sqlParam32.Value)
....but I don't really want to have to manipulate the string on the
receiving page.
Here's my code:
code extract -----------------------
Dim sqlParam30 As
SqlParameter
=3D New
SqlParameter
("@intCustomerID",
SqlDbType
.Int, 4)
sqlParam30.Direction =3D
ParameterDirection
.Output
myCommand.Parameters.Add(sqlParam30)
Dim sqlParam31 As
SqlParameter
=3D New
SqlParameter
("@intInvoiceID",
SqlDbType
.Int, 4)
sqlParam31.Direction =3D
ParameterDirection
.Output
myCommand.Parameters.Add(sqlParam31)
Dim sqlParam32 As
SqlParameter
=3D New
SqlParameter
("@intDeliveryID",
SqlDbType
.Int, 4)
sqlParam32.Direction =3D
ParameterDirection
.Output
myCommand.Parameters.Add(sqlParam32)
'## Open the connection and execute the Command
MyConnection.Open()
myCommand.ExecuteNonQuery()
MyConnection.Close()
'## Return the ID's
Return (sqlParam30.Value)
Return (sqlParam31.Value)
Return (sqlParam32.Value)
end extract ---------------------------
Regards,
Jason
| [aspngvb] member
Click here to reveal e-mail address
=3D YOUR ID=20
|
http://www.asplists.com/asplists/aspngvb.asp
=3D JOIN/QUIT
Reply to this message...
=?iso-8859-1?Q?Jo=E3o_Carreiro?=
You could do it by=20
1 - Defining an enum and returning that enum
Enum myReturnValues
Value1 as Integer
Value2 as Integer
Value3 as Integer
End Enum
Function YourFunction() as myReturnValues
2- Return an array
Function YourFunction() as Integer()
3 - By using ByRef Values
Sub YourFunction (ByRef Val1, ByRef Val2, ByRef Val3)
Jo=E3o Carreiro
-----Original Message-----
From: Jason Hick [mailto:
Click here to reveal e-mail address
]
Sent: 02 July 2002 10:06
To: aspngvb
Subject: [aspngvb] HELP: Returning multiple values from a function
-- Moved from [aspngfreeforall] to [aspngvb] by Tim Musschoot
<
Click here to reveal e-mail address
> --
Hi,
This might be a really basic question, so apologies in advance!!
I've got a function that needs to return 3 values (Outputs from a =
stored
procedure), but I can only seem to retrieve 1 of the values on my ASP =
page.
Is it possible to do this using my code below? I've managed to return =
all 3
values as a string...
Return CInt(sqlParam30.Value) & "|" & CInt(sqlParam31.Value) & "|" &
CInt(sqlParam32.Value)
....but I don't really want to have to manipulate the string on the
receiving page.
Here's my code:
code extract -----------------------
Dim sqlParam30 As
SqlParameter
=3D New =
SqlParameter
("@intCustomerID",
SqlDbType
.Int, 4)
sqlParam30.Direction =3D
ParameterDirection
.Output
myCommand.Parameters.Add(sqlParam30)
Dim sqlParam31 As
SqlParameter
=3D New =
SqlParameter
("@intInvoiceID",
SqlDbType
.Int, 4)
sqlParam31.Direction =3D
ParameterDirection
.Output
myCommand.Parameters.Add(sqlParam31)
Dim sqlParam32 As
SqlParameter
=3D New =
SqlParameter
("@intDeliveryID",
SqlDbType
.Int, 4)
sqlParam32.Direction =3D
ParameterDirection
.Output
myCommand.Parameters.Add(sqlParam32)
'## Open the connection and execute the Command
MyConnection.Open()
myCommand.ExecuteNonQuery()
MyConnection.Close()
'## Return the ID's
Return (sqlParam30.Value)
Return (sqlParam31.Value)
Return (sqlParam32.Value)
end extract ---------------------------
Regards,
Jason
| [aspngvb] member
Click here to reveal e-mail address
=3D YOUR ID
|
http://www.asplists.com/asplists/aspngvb.asp
=3D JOIN/QUIT
_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered
through the MessageLabs Virus Control Centre. For further information =
visit
http://www.star.net.uk/stats.asp=20
=20
IMPORTANT NOTICE=20
This communication contains information, which is confidential and may =
also
be privileged. It is for the exclusive use of the intended =
recipient(s). If
you are not the intended recipient(s) please note that any form of
distribution, copying or use of this communication or the information =
in it
is strictly prohibited and may be unlawful. If you have received this
communication in error please return it to the sender. The opinions
expressed within this communication are not necessarily those expressed =
by
Teletext Ltd.=20
Teletext Ltd.=20
101 Farm Lane=20
Fulham=20
London SW6 1QJ=20
Registered in England number 2694814
_____________________________________________________________________
This message has been checked for all known viruses by Star Internet delivered
through the MessageLabs Virus Control Centre. For further information visit
http://www.star.net.uk/stats.asp
Reply to this message...
=?iso-8859-1?Q?Jo=E3o_Carreiro?=
Sorry, where I said "Enum" I meant Structure
So:
Structure myReturnValues
Value1 as Integer
Value2 as Integer
Value3 as Integer
End Structure
-----Original Message-----
From: Jo=E3o Carreiro [mailto:
Click here to reveal e-mail address
]
Sent: 02 July 2002 19:27
To: aspngvb
Subject: [aspngvb] RE: HELP: Returning multiple values from a function
You could do it by=20
1 - Defining an enum and returning that enum
Enum myReturnValues
Value1 as Integer
Value2 as Integer
Value3 as Integer
End Enum
Function YourFunction() as myReturnValues
2- Return an array
Function YourFunction() as Integer()
3 - By using ByRef Values
Sub YourFunction (ByRef Val1, ByRef Val2, ByRef Val3)
Jo=E3o Carreiro
-----Original Message-----
From: Jason Hick [mailto:
Click here to reveal e-mail address
]
Sent: 02 July 2002 10:06
To: aspngvb
Subject: [aspngvb] HELP: Returning multiple values from a function
-- Moved from [aspngfreeforall] to [aspngvb] by Tim Musschoot
<
Click here to reveal e-mail address
> --
Hi,
This might be a really basic question, so apologies in advance!!
I've got a function that needs to return 3 values (Outputs from a =
stored
procedure), but I can only seem to retrieve 1 of the values on my ASP =
page.
Is it possible to do this using my code below? I've managed to return =
all 3
values as a string...
Return CInt(sqlParam30.Value) & "|" & CInt(sqlParam31.Value) & "|" &
CInt(sqlParam32.Value)
....but I don't really want to have to manipulate the string on the
receiving page.
Here's my code:
code extract -----------------------
Dim sqlParam30 As
SqlParameter
=3D New =
SqlParameter
("@intCustomerID",
SqlDbType
.Int, 4)
sqlParam30.Direction =3D
ParameterDirection
.Output
myCommand.Parameters.Add(sqlParam30)
Dim sqlParam31 As
SqlParameter
=3D New =
SqlParameter
("@intInvoiceID",
SqlDbType
.Int, 4)
sqlParam31.Direction =3D
ParameterDirection
.Output
myCommand.Parameters.Add(sqlParam31)
Dim sqlParam32 As
SqlParameter
=3D New =
SqlParameter
("@intDeliveryID",
SqlDbType
.Int, 4)
sqlParam32.Direction =3D
ParameterDirection
.Output
myCommand.Parameters.Add(sqlParam32)
'## Open the connection and execute the Command
MyConnection.Open()
myCommand.ExecuteNonQuery()
MyConnection.Close()
'## Return the ID's
Return (sqlParam30.Value)
Return (sqlParam31.Value)
Return (sqlParam32.Value)
end extract ---------------------------
Regards,
Jason
| [aspngvb] member
Click here to reveal e-mail address
=3D YOUR ID
|
http://www.asplists.com/asplists/aspngvb.asp
=3D JOIN/QUIT
_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered
through the MessageLabs Virus Control Centre. For further information =
visit
http://www.star.net.uk/stats.asp=20
=20
IMPORTANT NOTICE=20
This communication contains information, which is confidential and may =
also
be privileged. It is for the exclusive use of the intended =
recipient(s). If
you are not the intended recipient(s) please note that any form of
distribution, copying or use of this communication or the information =
in it
is strictly prohibited and may be unlawful. If you have received this
communication in error please return it to the sender. The opinions
expressed within this communication are not necessarily those expressed =
by
Teletext Ltd.=20
Teletext Ltd.=20
101 Farm Lane=20
Fulham=20
London SW6 1QJ=20
Registered in England number 2694814
_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered
through the MessageLabs Virus Control Centre. For further information =
visit
http://www.star.net.uk/stats.asp=20
=20
| [aspngvb] member
Click here to reveal e-mail address
=3D YOUR ID
|
http://www.asplists.com/asplists/aspngvb.asp
=3D JOIN/QUIT
IMPORTANT NOTICE=20
This communication contains information, which is confidential and may =
also
be privileged. It is for the exclusive use of the intended =
recipient(s). If
you are not the intended recipient(s) please note that any form of
distribution, copying or use of this communication or the information =
in it
is strictly prohibited and may be unlawful. If you have received this
communication in error please return it to the sender. The opinions
expressed within this communication are not necessarily those expressed =
by
Teletext Ltd.=20
Teletext Ltd.=20
101 Farm Lane=20
Fulham=20
London SW6 1QJ=20
Registered in England number 2694814
_____________________________________________________________________
This message has been checked for all known viruses by Star Internet delivered
through the MessageLabs Virus Control Centre. For further information visit
http://www.star.net.uk/stats.asp
Reply to this message...
=?iso-8859-1?q?mallika=20banu?=
--- "Guillermo E. Rivero" <
Click here to reveal e-mail address
>
wrote: > You can create a class with 3 fields, 1 for
each
[Original message clipped]
________________________________________________________________________
Want to sell your car? advertise on Yahoo Autos Classifieds. It's Free!!
visit http://in.autos.yahoo.com
Reply to this message...
Darren Neimke
You've got 3 basic options:
- Use globally scoped variables
- Pass in a struct Type with 3 fields
- Pass fields in ByRef
Bear in mind with the first option that I mentioned, that you should
always try to minimize variable scoping so that would be the least
desirable.
-----Original Message-----
From: mallika banu [mailto:
Click here to reveal e-mail address
]=20
Sent: Thursday, July 04, 2002 4:01 PM
To: aspngvb
Subject: [aspngvb] RE: HELP: Returning multiple values from a function
Reply to this message...
System.Data.ParameterDirection
System.Data.SqlClient.SqlParameter
System.Data.SqlDbType
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com