我正在開發一個C#VS2008/SQL Server網站應用程序。我從來沒有使用過Dictionary類,但我試圖用Dictionary變量替換我的Hashtable。如何將字典變量傳遞給另一個過程
這裏是我的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'to'string'
如何將整個openWith變量傳遞給AppendDataCT? AppendDataCT是調用我的SQL存儲過程的方法。我想傳入整行,其中每行都有一組我想要添加到數據庫表中的唯一值。例如,如果每行都需要單元格A,B和C的值,那麼我想將這3個值傳遞給AppendDataCT,其中所有這些值都是字符串。我如何用Dictionary來做到這一點?
從字典中提取並作爲字符串傳遞 – 2010-06-07 05:02:50