473,463 Members | 1,532 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

using params with out.

hi All,

Iam facing a peculiar problem, where i would like to parse the passed
parameters and would like to figure out which ones are marked 'out'. For
example the method signature is

public DataSet SearchItems(string procname, params objects[] values)
{
// call database here
}

and calling code can look like

int count;
DataSet ds = SearchItems("usp_searchme","John","Doe",out count);

In the SearchItems i would like to pass the count as out paramater to
the stored proc and would like to fetch its value back

Any ideas how i could implement this ?

thanks


Jun 29 '06 #1
3 1297
I don't think you can do this with the params syntax; however, if you can
(at the caller) create an object[] to pass in, the method should be able to
update the elements inside the array, and then the caller should be able to
access the updated values (since only the address to the array is really
passed over). Of course, (as always with object[] arguments) this doesn't
really tell you much about the params...

e.g. (note I have left it as "params" to allow simple usage when only
passing values in)

static void Main() {
object[] args = new object[] {"John","Doe",null};
DataSet ds = SearchItems("usp_searchme",args);
int rows = (int) args[2];
}
static DataSet SearchItems(string procname, params object[] values)
{
values[2] = 37;
return null;
}

Marc
Jun 29 '06 #2
Ashish,
If the "values" object array contains SqlParameters (or OleDb- whatever you
are using), then you should be able to case each element to an instance of
the SqlParameter class and check its ParameterDirection property.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Ashish" wrote:
hi All,

Iam facing a peculiar problem, where i would like to parse the passed
parameters and would like to figure out which ones are marked 'out'. For
example the method signature is

public DataSet SearchItems(string procname, params objects[] values)
{
// call database here
}

and calling code can look like

int count;
DataSet ds = SearchItems("usp_searchme","John","Doe",out count);

In the SearchItems i would like to pass the count as out paramater to
the stored proc and would like to fetch its value back

Any ideas how i could implement this ?

thanks


Jun 29 '06 #3
>> Any ideas how i could implement this ?

Very easily: Give methods with different signatures, different names!

What exactly are you gaining by funneling all your data access through
one method?

Why not have a method:

DataSet SearchMe (string firstName, string lastName, out int count);

Now you have no need whatsoever to analysis your parameters. You just
pass them to the stored procedure & get your data back.

Ashish wrote:
hi All,

Iam facing a peculiar problem, where i would like to parse the passed
parameters and would like to figure out which ones are marked 'out'. For
example the method signature is

public DataSet SearchItems(string procname, params objects[] values)
{
// call database here
}

and calling code can look like

int count;
DataSet ds = SearchItems("usp_searchme","John","Doe",out count);

In the SearchItems i would like to pass the count as out paramater to
the stored proc and would like to fetch its value back

Any ideas how i could implement this ?

thanks


Jun 29 '06 #4

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

Similar topics

4
by: Leslie Houk | last post by:
I'm just learning PHP, and I'm having a problem using fpassthru(). I want to download a file using the following code segment I found, which I put into my testing file called portal.php: ...
0
by: David Wright | last post by:
I am running Red Hat 8.0 and have pear enabled in PHP. I have installed the Socket.php in the PEAR Net/ directory. When I run this test script It displays the "Mail has been sent message" but no...
1
by: SPG | last post by:
Hi, I have a servlet application that I am trying to write a very basic load tester for. There application has several servlets, but all rely on the same session being used (IE: For logged in...
1
by: Brian Beck | last post by:
Hi. I'm having some problems with code based directly on the following httplib documentation code: http://www.zvon.org/other/python/doc21/lib/httplib-examples.html I've included the code and...
9
by: Roger Withnell | last post by:
I'm inserting a new record into an MS SQL database table and I want to obtain the new records autonumber immediately afterwards, as follows: MadminRS.CursorLocation = adUseServer...
1
by: trapeze.jsg | last post by:
Hi. I am trying to get through to Microsoft MapPoint Services using ZSI for soap handling. I can generate the service classes and also the soap-requests generated by the service classes seem to...
0
by: Mike | last post by:
Hi, I am trying to insert parameters into a stored procedure using DAAB (see code at the bottom of this post). I am getting the following error: Object reference not set to an instance of an...
8
by: Ed Jay | last post by:
I want to use history.go() to navigate between my previously loaded pages. I'm looking for a way to trigger a function call when a page is accessed using history.go(). Is there an event generated?...
0
by: suneethakanchana | last post by:
HI my xml structure is <?xml version="1.0" encoding="UTF-8" ?> <PARAMETERS xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="EV_Parameters.xsd"> ...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.