How to pass a Dictionary variable to another procedure

Posted by salvationishere on Stack Overflow See other posts from Stack Overflow or by salvationishere
Published on 2010-06-07T04:56:45Z Indexed on 2010/06/07 5:02 UTC
Read the original article Hit count: 274

I am developing a C# VS2008/SQL Server website application. I've never used the Dictionary class before, but I am trying to replace my Hashtable with a Dictionary variable.

Here is a portion of my aspx.cs code:

...
Dictionary<string, string> openWith = new Dictionary<string, string>(); 

for (int col = 0; col < headers.Length; col++)
{
   @temp = (col + 1);
   @tempS = @temp.ToString();
   @tempT = "@col" + @temp.ToString();
   ...
   openWith.Add(@tempT, headers[col]);
}
...
for (int r = 0; r < myInputFile.Rows.Count; r++)
 { resultLabel.Text = ADONET_methods.AppendDataCT(myInputFile, openWith); }

But this is giving me a compiler error on this last line: Argument '2': cannot convert from 'System.Collections.Generic.Dictionary' to 'string'

How do I pass the entire openWith variable to AppendDataCT? AppendDataCT is the method that calls my SQL stored proc. I want to pass in the whole row where each row has a unique set of values that I want to add to my database table. For example, if each row requires values for cells A, B, and C, then I want to pass these 3 values to AppendDataCT, where all of these values are strings. How do I do this with Dictionary?

© Stack Overflow or respective owner

Related posts about c#

Related posts about sql-server-2005