Pass optional parameters to a method in a Dictionary (C#2.0) ?

Hi,

We have some test code where we would want to invoke a method with
optional parameters.

In C# 4.0, I believe we could use named parameters, but we're using C#
2.0

I found a Dictionary solved my problem, but I'm not sure it's the best
pattern for C# 2.0?.

Could anyone please comment on whether or not there's a more
appropriate pattern?

Cheers

artie

EXAMPLE:

public void AddToDatabase(Dictionary<string,object> fields)
{
   string _surname = "";
   string _city = "";
   int _employeeId;

   if (fields.ContainsKey("surname") _surname =
(string)fields["surname"];
   if (fields.ContainsKey("city") _city = (string)fields["city"];
   if (fields.ContainsKey("employee_id") _employeeId =
(int)fields["employee_id"];
....
   // assemble SQL with the above parameters and execute SQL to write
to the database
....
}

USE:
public void Test()
{
....
	Dictionary<string, object> fields = new Dictionary<string, object>();
	fields.Add("surname", _localSurnameVariable);
....
	fields.Add("city_id", _localCityVariable);
	AddToDatabase(values);
....
}

public void AnotherTest()
{
....
	Dictionary<string, object> fields = new Dictionary<string, object>();
    // doesn't care about any other attributes, so only adds the
employee_id
	fields.Add("employee_id", _localEmployeeId);
....
	AddToDatabase(values);
....
}
0
Artie
2/10/2010 8:11:00 AM
dotnet.languages.csharp 1931 articles. 0 followers. Follow

10 Replies
1012 Views

Similar Articles

[PageSpeed] 21

Artie wrote:
> Hi,
> 
> We have some test code where we would want to invoke a method with
> optional parameters.
> 
> In C# 4.0, I believe we could use named parameters, but we're using C#
> 2.0
> 
> I found a Dictionary solved my problem, but I'm not sure it's the best
> pattern for C# 2.0?.
> 
> Could anyone please comment on whether or not there's a more
> appropriate pattern?
> 

You could (sort of), but whether you should depends on what exactly you 
want to achieve. The fact that everything relies on (hard coded) strings
makes it easy to make mistakes. Accidentally adding "Surname" instead of 
"surname" to the dictionary will break the system. This could be 
countered by either using constants (and praying that everyone in your 
team will always use them), or by providing support routines (or using a 
custom dictionary), to always convert to upper- or lowercase. Besides 
the fragility of the code, it will also be a nightmare to maintain.

But from the provided example, it's hard to tell what the greater scheme 
of things is. That makes it hard to suggest something better. The 
"AddToDatabase" presumably is a somewhat generic method to render SQL to 
add any kind of data to the database. Where does that data come from?

Is it important to know which fields are in the dictionary for the 
AddToDatabase method? If not, it could also just simply regard the 
key-value pairs as "fields with values that have to be emitted in SQL" 
(although there doesn't seem to be a provision to specify a table in the 
method).

Maybe there are classes in your model that are knowledgeable about how 
to generate sql (a business objects in your domain might be repsonsible 
for generating their own crud SQL for instance), without having to 
resort to evaluating key-value pairs in a dictionary.


-- 
   Willem van Rumpt
0
Willem
2/10/2010 9:09:07 AM
On 2/10/2010 4:11 PM, Artie wrote:
> Hi,
>
> We have some test code where we would want to invoke a method with
> optional parameters.
>
> In C# 4.0, I believe we could use named parameters, but we're using C#
> 2.0
>
> I found a Dictionary solved my problem, but I'm not sure it's the best
> pattern for C# 2.0?.
>
> Could anyone please comment on whether or not there's a more
> appropriate pattern?
>
> Cheers
>
> artie
>
> EXAMPLE:
>
> public void AddToDatabase(Dictionary<string,object>  fields)
> {
>     string _surname = "";
>     string _city = "";
>     int _employeeId;
>
>     if (fields.ContainsKey("surname") _surname =
> (string)fields["surname"];
>     if (fields.ContainsKey("city") _city = (string)fields["city"];
>     if (fields.ContainsKey("employee_id") _employeeId =
> (int)fields["employee_id"];
> ....
>     // assemble SQL with the above parameters and execute SQL to write
> to the database
> ....
> }
>
> USE:
> public void Test()
> {
> ....
> 	Dictionary<string, object>  fields = new Dictionary<string, object>();
> 	fields.Add("surname", _localSurnameVariable);
> ....
> 	fields.Add("city_id", _localCityVariable);
> 	AddToDatabase(values);
> ....
> }
>
> public void AnotherTest()
> {
> ....
> 	Dictionary<string, object>  fields = new Dictionary<string, object>();
>      // doesn't care about any other attributes, so only adds the
> employee_id
> 	fields.Add("employee_id", _localEmployeeId);
> ....
> 	AddToDatabase(values);
> ....
> }

Hi,

I'm not sure why you go down that path... Isn't below would do what you 
need?

public void AddToDatabase(string surname, string city, int employeeId)
{
   // do something
}

public void AddToDatabase(int employeeId)
{
   AddToDatabase("", "", employeeId);
}

// another overload for example
public void AddToDatabase(string surname, int employeeId)
{
   AddToDatabase(surname, "", employeeId);
}

???

You can have as many method overloads you want.

Regards.
0
kndg
2/10/2010 9:35:45 AM
Hmm... okay, seems you're aftering the named parameter.
Your solution would do, but... hmm... hmm... maybe someone can suggest a 
better approach?
0
kndg
2/10/2010 10:08:35 AM
"Artie" <artieleech@yahoo.co.uk> wrote in message 
news:a9eff9e3-24e8-4f7a-8805-11c12bed27ea@v25g2000yqk.googlegroups.com...
<<>>
> public void AddToDatabase(Dictionary<string,object> fields)
> {
>   string _surname = "";
>   string _city = "";
>   int _employeeId;
>
>   if (fields.ContainsKey("surname") _surname =
> (string)fields["surname"];
>   if (fields.ContainsKey("city") _city = (string)fields["city"];
>   if (fields.ContainsKey("employee_id") _employeeId =
> (int)fields["employee_id"];
> ...
>   // assemble SQL with the above parameters and execute SQL to write
> to the database
<<>>

Is this just to insert data in a regular database?

My first question in your position would be whether I could possibly instead 
use a class per table.
Generics, typed lists and all that made .Net2 way easier.
Strongly typed means you don't have people breaking it like you can 
dictionaries.

So - the thing to understand first is whether this is a data access layer 
gone mad or there's some specific constraint/problem  means you can't have a 
class.

Generating the classes is relatively easy, I could provide a simplistic 
application if you don't like ORM commercialy available. 

0
Andy
2/10/2010 3:14:04 PM
On Feb 10, 8:11=A0am, Artie <artiele...@yahoo.co.uk> wrote:
> Hi,
>
> We have some test code where we would want to invoke a method with
> optional parameters.
>
> In C# 4.0, I believe we could use named parameters, but we're using C#
> 2.0
>
> I found a Dictionary solved my problem, but I'm not sure it's the best
> pattern for C# 2.0?.
>
> Could anyone please comment on whether or not there's a more
> appropriate pattern?
>
> Cheers
>
> artie
>
> EXAMPLE:
>
> public void AddToDatabase(Dictionary<string,object> fields)
> {
> =A0 =A0string _surname =3D "";
> =A0 =A0string _city =3D "";
> =A0 =A0int _employeeId;
>
> =A0 =A0if (fields.ContainsKey("surname") _surname =3D
> (string)fields["surname"];
> =A0 =A0if (fields.ContainsKey("city") _city =3D (string)fields["city"];
> =A0 =A0if (fields.ContainsKey("employee_id") _employeeId =3D
> (int)fields["employee_id"];
> ...
> =A0 =A0// assemble SQL with the above parameters and execute SQL to write
> to the database
> ...
>
> }
>
> USE:
> public void Test()
> {
> ...
> =A0 =A0 =A0 =A0 Dictionary<string, object> fields =3D new Dictionary<stri=
ng, object>();
> =A0 =A0 =A0 =A0 fields.Add("surname", _localSurnameVariable);
> ...
> =A0 =A0 =A0 =A0 fields.Add("city_id", _localCityVariable);
> =A0 =A0 =A0 =A0 AddToDatabase(values);
> ...
>
> }
>
> public void AnotherTest()
> {
> ...
> =A0 =A0 =A0 =A0 Dictionary<string, object> fields =3D new Dictionary<stri=
ng, object>();
> =A0 =A0 // doesn't care about any other attributes, so only adds the
> employee_id
> =A0 =A0 =A0 =A0 fields.Add("employee_id", _localEmployeeId);
> ...
> =A0 =A0 =A0 =A0 AddToDatabase(values);
> ...
>
> }

Thanks for all your responses guys, very much appreciated.

We did have 2 overloaded functions to begin with, but it looked like
we were going to end up with a large number, just to cope with each
individual scenario where different clients of the method would want
to omit certain parameters.  So, C#4.0's named parameters would have
solved it perfectly.

I shouldn't have been so specific about what the method being called
is going to do with the data - just the fact that there IS a method
which has a number of clients, and we were looking for a way to handle
this without creating lots of overloaded functions - we have
previously used the pattern described by kndg.

The system we're working on is already a mess, and we're finding it
hard to work round bad designs.

The AddToDatabase method does already exist, but project contraints
(the usual - time and budget) mean that we can't refactor as much as
we'd like, so I wanted the quickest, best way to make this method
useable by a number of other methods, and making one version of it -
with the Dictionary - was the first thing that came to mind.

Thanks again for all your suggestions!

artie
0
Artie
2/10/2010 5:31:46 PM
Artie wrote:
> [...]
> We did have 2 overloaded functions to begin with, but it looked like
> we were going to end up with a large number, just to cope with each
> individual scenario where different clients of the method would want
> to omit certain parameters.  So, C#4.0's named parameters would have
> solved it perfectly.

Opinions vary, of course.  But my opinion is that if you'd have so many 
parameters that the number of overloads would have been problematic, 
then you'd have too many parameters to even go with named parameters.

Granted, I'm somewhat biased against named parameters anyway.  They were 
added to C# primarily as a solution to dealing with COM interop issues, 
to reduce that as a "pain point".  Lots of COM interfaces, especially 
those from Office, have a very large number of optional parameters, and 
along with the addition of the "dynamic" type, optional parameters are 
intended mainly to help with that.

But of course, once something is in the language, people will use it for 
other purposes too.

I think named parameters can help a lot when you have optional 
parameters all of the same type, but even there one should be careful to 
have very few parameters.  IMHO, a method with more than three or four 
parameters is asking for refactoring somehow, and once you get up to a 
half-dozen or more, that just seems like a poor design choice.

> I shouldn't have been so specific about what the method being called
> is going to do with the data - just the fact that there IS a method
> which has a number of clients, and we were looking for a way to handle
> this without creating lots of overloaded functions - we have
> previously used the pattern described by kndg.
> 
> The system we're working on is already a mess, and we're finding it
> hard to work round bad designs.

If you're stuck with the design, you're stuck with it.  But I think that 
if there are so many optional parameters that overloading is 
problematic, the dictionary-based approach is superior.  I would use an 
enum, rather than strings, as the key for the dictionary.  That will 
avoid spelling errors, etc.

Of course, if you have the opportunity to clean up the API itself so 
that all these optional parameters aren't even needed, even better.  But 
obviously that's not always possible.

Pete
0
Peter
2/10/2010 7:06:53 PM
On 10 Feb, 19:06, Peter Duniho <no.peted.s...@no.nwlink.spam.com>
wrote:
> Artie wrote:
> > [...]
>
> If you're stuck with the design, you're stuck with it. =A0But I think tha=
t
> if there are so many optional parameters that overloading is
> problematic, the dictionary-based approach is superior. =A0I would use an
> enum, rather than strings, as the key for the dictionary. =A0That will
> avoid spelling errors, etc.
>
> Pete

Hi Pete,

Thanks for your response.

I've used Named Parameters in a very similar way, years ago, when I
used Ada.  We used them for this very scenario and it worked well.

I agree that enum would give stronger typing, so I'll change it to use
enums rather than the strings.

Thanks

artie
0
Artie
2/11/2010 7:12:59 AM
"Artie" <artieleech@yahoo.co.uk> wrote in message 
news:6f681e80-e4d8-498d-a2e5-b4b147934ff4@36g2000yqu.googlegroups.com...

>I agree that enum would give stronger typing, so I'll change it to use
>enums rather than the strings.

I get that you don't want to refactor code and you're short of time.
My reasoning:

If you use enums you have to:
Generate the enums somehow for each table. Click, paste.
Change  your  update code to use them.

If you use classes and hand over a typed object (or obviate that bit of 
code ) you have to.
Generate your classes somehow for each table. Click, paste.
Change all your update code to use them.

Obviously you know your staff and project better than I do.
On the face of it the two approaches seem likely to require similar effort.
Your code generation produces more text for a complete type but what the 
hell.
Classes offer stronger typing (than enums) and other potential benefits such 
as converting data format between the data store and view.

0
Andy
2/11/2010 10:28:27 AM
A class would be a great approach, even 3.0 allows object construction a 
little bit like XML / F#  ; like in here, for  our object "titi":

----------------------
    class Program
    {
        static void Main(string[] args)
        {
            toto titi = new toto { totoInt = 3,
                                    totoString = "toto",
                                    totoDouble = 3.4 };
        }

    }

    internal class toto
    {
        public int totoInt;
        public double totoDouble;
        public string totoString;
        public decimal totoDecimal;
    }
--------------------

Sure, it is not exactly like what the OP describes, since the ***involved*** 
properties have to be known at coding time... but the same will hold for 
using named parameters, no?


Vanderghast, Access  MVP

0
vanderghast
2/11/2010 4:41:19 PM
"vanderghast" <vanderghast@com> wrote in message 
news:4A2DA57B-0E2C-4655-9774-D33AF091D420@microsoft.com...
>A class would be a great approach, even 3.0 allows object construction a 
>little bit like XML / F#  ; like in here, for  our object "titi":
<>
> Sure, it is not exactly like what the OP describes, since the 
> ***involved*** properties have to be known at coding time... but the same 
> will hold for using named parameters, no?
>
>
> Vanderghast, Access  MVP
>

With straight .net 2 you'd have to create the object, set properties then 
hand the project over.
Seems to me if the team have stopped writing code then just stick with the 
approach as is.
If the team are still writing code then staying with an inherently faulted 
approach is false economy.
Errm.
If it was economy.

Maybe there's something else we don't know. 

0
Andy
2/11/2010 7:39:01 PM
Reply:

Similar Artilces:

Is It Possible To Pass Parameters to A Pass Through Query
My assumption is that's it's not. At work I use ODBC to connect to our oracle database with Access 2003. There are cases where using a pass through query runs much much faster and I then use it in a make table query to make a local table. In access you can use brackets [] to have it ask for input. May I assume there is no way to do anything like that in a pass through query? Create a PassThrough query and use code to assign the SQL to this query filtering it with a parameter, and then run it e.g Dim MyVariable As Integer MyVariable = InputBox("Please select a Number&quo...

Hand made method injection and prop.injection
I got to know about constructor injection I could not find any code snippet or much details about method injection and property injection by hand. All the links talks about how this can be achieved by using framework like Spring etc., Any help would be appreciated much. Source code is available for some of the various frameworks like Ninject. I'd start with that. ...

CRM 4.0
Hi, I have upgraded to CRM 4.0 with outlook client. Contacts and accounts are not populating in the address book, while queues and users information are all in there. Any ideas?? Thanks Check your options for the address book. By default, CRM 4.0 only adds contacts and accounts that you own to the address book. If you are not the owner of the records they will not show up but you can change this setting. -- Jason Roy "crmguru" wrote: > Hi, > > I have upgraded to CRM 4.0 with outlook client. > > Contacts and accounts are not populating in the address b...

Business card #2
Just tried to make a business card and then print it. Previous version of Publisher had many Avery business card types (numbers). Where did they all go in Publisher 2003? I can't seem to find the one I need? WWV Wayne Veale wrote: > Just tried to make a business card and then print it. > Previous version of Publisher had many Avery business > card types (numbers). Where did they all go in Publisher > 2003? I can't seem to find the one I need? > WWV ===================================== Maybe you had MS Picture It! Publishing... MS Publisher (a completely different...

Can't boot or access C drive
Windows XP won't boot. I tried reinstalling Windows but keep getting a blue screen even after deleting, recreating and formatting the C drive. I booted with an MSDOS floppy but can't access C drive. It may be a boot sector virus. How do I format the entire hard drive so I can do a clean install? "rj" <rjnothere@netzero.net> wrote in message news:ulZXW#DJLHA.1868@TK2MSFTNGP05.phx.gbl... > Windows XP won't boot. I tried reinstalling Windows but keep getting a > blue > screen even after deleting, recreating and formatting the C drive. I &g...

Report Parameter not displaying correct results
Hey there, I have a parameter form that you can choose a Description from or ALL. Its based on this query: SELECT Description, 1 AS SortColumn FROM Study UNION SELECT "All", 0 FROM Study ORDER BY SortColumn, [Description]; When I choose ALL I get no data on my report when there is data. MY RecordSource for the report is: SELECT Study.Description, Study.Product, Study.Dosage FROM Study WHERE ((Study.Description)=forms!SelectTrial!txtDescription) OR((forms!SelectTrial!txtDescription)="ALL") If I choose ALL shouldn't all my Descriptions show up on the ...

Update #2
I use Money 2002. Are there any serious differences among 2006's versions of Money with the one I use? I live in Greece and I can't try the trial version, it's only for US residents! But how can I know for sure that the new versions have such improvements that are worth it to buy one? Thank you for your help!! First of all 2007 is about to be released any week. I am using 2004 but I have 2005 & 2006 but there are performance issues and also the interface is not as good as 2004. I would say if you are happy and not in need of anything special, stick with what you got. -...

Updating Links Option
When I get the message "This workbook contains links to other data sources" I can't imagine what "other data" they are referring to. How can I find out the source of this "other data" Thanks in advance Dave When I can't find links, I'll use Bill Manville's FindLink program: http://www.oaltd.co.uk/MVP/Default.htm It does a much better job searching for them than I can do. Dave wrote: > > When I get the message "This workbook contains links to other data sources" > I can't imagine what "other data" they are...

Puzzles in the development of Nand Flash Driver under Wince 5.0
Dear friends, thanks advance for your assistance The following is the detail for my case: Platform: PXA270, Os: Wince 5.0 FileSys: TFAT NAND Flash: Sector/Page Size:2048bytes; Number of Sectors per Block:64; Number of Block:8192 As the information above indicates, The total store space is 1G bytes(of cause, from the memory storage menager, these indexs are all consistent with that via the FMD_GetflashInfo) but I have never made full use of them. In the tests, When I program about 300-500M bytes, the system would show me ECC check error, and then, the whole file syste...

Linked Reports Parameters
How I can pass data from CRM to a linked Report (such as parametrs to reporting services report: CRM_Url, CRM_FilterText etc). I need to pass entity data (for examle EntityId) on aspx page. This may be what you are looking for. I use it to pass Account ID, Opportunity ID's etc... to my RS reports from buttons in CRM created using the isv.config file. Running CRM - MS SQL Reporting Services (RS) from ISV button and passing in Account/Opportunity GUID parameters to report. Here is a method of running an RS report from CRM and passing in the GUID from the record you are on to the RS re...

Exchange not able to send mail #5.5.0 Relay Error
Hi, Our Exchange Server 2003 on SBS2003 has just ground to a halt from sending e-mails (SMTP using ETRN). Apparently its something to do with authentication and ISPs using this method to stop spam. It keeps returning to the sender with the message about 550 #5.5.0 Relay. It wont let any outbound mail touch anybody who's ISP/Mail Servers runs a reverse lookup or something and blocks us because we look like we are acting as spammers. ANY HELP is gladly accepted and appreciated. Regards Chris White Stirling Technical Engineering Ltd. Microsoft Partners Dont worry guys, our server...

Hide rows if cells = 0.00
I am trying to hide rows if any cell in a columm = 0.00. Example: If any cell in column D = 0.00 than hide the row containing that cell. Highlight your data, then from the menu bar select Data > Filter > Autofilter. Select the drop-down in column D and choose Custom. Use the drop-downs to set your selection to read 'does not equal' '0.00', then click OK. Those rows with 0.00 in column D should now be filtered out (they're still in your data, just not visible). --Bruce "dford" wrote: > I am trying to hide rows if any cell in a columm = 0.00. Exa...

Pass multiple selected values from list box to table
How do I pass multiple selected values from a list box to a table? I've found code to use the values as criteria in a query but would now like to store the values in a table (at least temporarily) thanks in advance. jack Pass selected values from a list box to a table? I don't really think you want to do this. Can you describe more about what you are trying to accomplish? You just store raw data in a table. You don't store manipulated data in a table. Maybe you need a query to do what you want to do... -- Ryan--- If this information was helpful, please indi...

C++ application with HTML gui
I'd like to develop windows applications in C++/MFC where my application user interface is HTML. This allows much easier, squicker and graphically enhanced and even internet connected applications. Some time ago someone mentioned here that it wasn't trivial to let C++ code interact with HTML elements.. Like calling a C++ function when an HTML button <input type="button" ...> is pressed, reading out the text entered in an <input type="text" ..> etc. Microsoft really should make it easier to allow C++ code to interact with internet explorer events....

Deferrals #2
Is there an integration file for the deferrals module in GP? I need a solution for our user which makes entering financial deferrals less time consuming. We're currenly on GP v9. Hi Louella, We developed a more comphrehensive solution just for GP. http://www.binarystream.com/revenue_expense_deferrals.asp Feel free to contact us and discuss the differences. Darren "Louella" wrote: > Is there an integration file for the deferrals module in GP? > > I need a solution for our user which makes entering financial deferrals less > time consuming. We're cu...

'Email via Mail Merge' option missing -again, please, help
No 'Mail Merge' options (email, Letter) in the Create Quick Campaign Wizard are there. I am using the Outlook client, the option 'Enable Direct E-mail via Mail Merge' is selected in System settings, approptiate roles are assigned. Outlook and web client use differenet URL, they are not running at the same time (just Outlook is running). I deleted all cookies and closed all Explorer windows - nothing helps :-(( Is your Outlook and Word the same release? ie. You have both Outlook 2003 and Word 2003? "zen" wrote: > No 'Mail Merge' options (email, L...

Visual C++ / DragDrop / MouseMove / Focus
Hi I like to implement drag and drop funtionality. If I drag a file from the explorer over my application, my app does not have the focus (the explorer has it). My problem: When moving the draged file over my app I want to handle the mousemove event. How can I get the focus back to my application? ThanX in advance dqueezer Take a look at DragAcceptFiles DragQueryFile DragQueryPoint DragFinish WM_DROPFILES Normand "Squeezer" <gierok@gmx.de> a �crit dans le message de news: 49d67a52.0401220615.748d6880@posting.google.com... > Hi > > I like to implement drag and dro...

Office trial to partial convert method
I installed Office 2007 professional 'trial' only to try out Outlook. Now that I am happy with Outlook, I have purchased Outlook 2007 with Business Contract Manager and installed the programme. However, since my original trial was for the whole Office professional, my outlook keeps telling me that my trial has expired and ask whether I want to convert it to full 'professional 2007'. Can someone please help me to stop this and to keep using Outlook without losing the currently stored data. Thank you very much for the valued help in advance. Kind regards, "Lutecia...

CString question #2
Hi, CString test = "Mystring 5" What member function should be use to get "5"? it doesn't work if I try to find position of " " int pos = Mystring.Find(" "); Thanks help! You meant to type... int pos= test.Find( _T(" ") ); right? On a side note, you should get used to wrapping your characters/strings in the _T() macro so if you ever end up writing UNICODE applications you won't run into problems. Like so... CString test = _T( "Mystring 5" ); char ch= _T('A'); HTH -- ============ Fra...

Job Link maintainence #2
when i try to link sales order in Job link maintainence window the following error occures. "An error has occured while attempting to run a query in the procdure TLinkerWindow.UpdateLinkedElements" Thanks ashraf .. First, make sure you have installed the Borland Database Engine, which can be found on your installation cd, on the client machine. It is under Additional Products -> Manufacturing. Second, the user that is logged in should have full rights to the folder where Great Plains is installed. There is a temp file that is created in that directory when the job li...

Flexibility in Line Item options
Hello, I am preparing a construction budget for some condos and I'd like to have a simple way to choose between different options for some of the line items (i.e. granite countertops instead of tile)... each would have its own cost implication and affect the bottom line. Any ideas? Thanks, Kalvin Mizzi Financial Analyst Equity Directions, Inc. Hi Kalvin If you make a data array with options and price as: Data array: Granite 3 Wood 4 Tile 5 You could use a validation list on the first column to make a dropdown menu and then a VLOOKUP() on the table array to change the price on the bo...

How to pass an object from C++
Hello! We have a C# asp.net web application that is using a COM dll We use the tlbimp to be able to use the COM dll from C# asp.net web application The method InitRules shown below is located in the COM dll. It can be seen below the text Original. Method InitRules below is called from C# but we want to pass an object of type Handle_DS in addition to all the other parameters. You can see the modified InitRules below marked Modified Note the object of type Handle_DS is a C++ object that is created from C# asp.net application and pass into the InitRules I have also copied the whole idl fil...

Send options for one receipent
I'd like to set one email receipent's send options to be different from others. When I start an email for this user I can go into options and set it's priority, a different reply address, etc. I want this to be the same for the receipent all the time. Is there away I can set a default for this? Hi M.Siler, TOOLS | EMAIL ACCOUNTS | View or change existing Accounts | There you can change the default account. Is this what you asking for? -- Ich habe nichts gemacht, gestern gings noch! Bitte in den Newsgroup antworten damit jeder etwas davon hat. Bravestar@Datenschutzministerium.de...

C# and SQL Server: Parallel vs. Sequential Writes (?)
Consider: - My SQL Server has 8 processors (cores actually). - I want to upload 8,000 records to a single table in my database. Which of these two would get the job done faster? (a) spawn 8 different threads in my client application and, using eight different sql connections, upload 1,000 entries on each thread, or (b) upload all 8,000 entries from the same thread. Option (a) would seem to make more effective use of all eight processors on the SQL Server. But in the final analysis, won't the SQL Server bottleneck be the transaction log where it has to ...

Data Dictionary with sample values
hi guys, I am going to create a data dictionary of our systems as I am sick of trying to find out what columns have been called in different tables. There is a hundred ways to do this but I am going to use INFORMATION_SCHEMA.COLUMNS to get the database, schema, table, column, type and length. So far so good. I also want the data dictionary to contain 'sample' data for each column so that you can see the types of values that are held in it. A query that looks something like this does the trick.. [code] SELECT TOP 5 * FROM ( SELECT Myfield as 'field',...