我正在开发一个C#VS2008 / SQL服务器的网站应用程序。 我以前从未使用过的Dictionary类的,但我想用字典变量来代替我的哈希表。
这里是我的aspx.cs代码的一部分:
...
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); }
但是,这是给我一个编译器错误在最后一行:参数“2”:无法从“System.Collections.Generic.Dictionary”转换为“字符串”
我如何通过整个openWith变量AppendDataCT? AppendDataCT是调用我的SQL存储过程的方法。 我想整个行,每一行都有一套独特的,我想添加到我的数据库表中值的传递。 例如,如果每一行需要用于小区A,B,和C,然后我想通过这些3个值来AppendDataCT,其中所有这些值是字符串值。 我怎样解释这样做呢?