473,946 Members | 13,328 Online
Bytes | Software Development & Data Engineering Community
+ 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(str ing procname, params objects[] values)
{
// call database here
}

and calling code can look like

int count;
DataSet ds = SearchItems("us p_searchme","Jo hn","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 1316
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",n ull};
DataSet ds = SearchItems("us p_searchme",arg s);
int rows = (int) args[2];
}
static DataSet SearchItems(str ing 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 ParameterDirect ion 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(str ing procname, params objects[] values)
{
// call database here
}

and calling code can look like

int count;
DataSet ds = SearchItems("us p_searchme","Jo hn","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(str ing procname, params objects[] values)
{
// call database here
}

and calling code can look like

int count;
DataSet ds = SearchItems("us p_searchme","Jo hn","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
2640
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: $fileString = './' . $params; // translate file name properly for Internet Explorer. if ( strstr( $_SERVER, "MSIE" )) { $params = preg_replace( '/\./', '%2e', $params, substr_count($params, '.') - 1 ); }
0
1424
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 mail arrives in my box. It was suggested by a friend that using PEAR was easier than setting up sendmail on my box. Any suggestions would be greatly appreciated. David
1
8581
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 users etc). I am trying to write a little test app to test the workflow of the servlet application. The problem is I need to keep the same session alive and post via that session.
1
2888
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 traceback at the end of this post. The odd thing is, using DEPRECATED FUNCTIONS to perform the same function works fine!
9
19941
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 MadminRS.CursorType = adOpenKeyset MadminRS.LockType = adLockOptimistic MadminRS.Open "NavBar", objConn, , , adCmdTable MadminRS.AddNew MadminRS("Url") = Request.Form("Website") MadminRS("ParentRecNo") = 0
1
3301
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 be OK. The problem I am facing is that I can't seem to authenticate myself. I have made a small change to ZSI.client so that when I get a "401 Unauthorized" response from the remote server I build up a nice authorization request:
0
1448
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 object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details:...
8
2679
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? Is there a method for detecting what page the user came from when a page is accessed using history.go()? -- Ed Jay (remove M to respond by email)
0
642
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"> <DATABASE db_name="EVOS"> <STORED_PROC sp_name="usp_GetModuleOwnersByModuleName">
0
10150
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11552
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11141
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11324
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
8240
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7403
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6318
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4524
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3525
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.