我嘗試將字符串[]添加到列表添加陣列列出具體的關鍵
代碼:
foreach (int software_id in softwarelist)
{
String sqlstring = "SELECT SoftwareName, Task_idn_Install, Task_idn_Deinstall, KZ, ParameterFeld FROM TUI_Software WHERE Sw_idn = '" + software_id + "'";
SqlCommand cmd1 = new SqlCommand(sqlstring, con);
SqlDataReader result_sw_info = cmd1.ExecuteReader();
if (result_sw_info.HasRows)
{
result_sw_info.Read();
softwarename = result_sw_info[0].ToString();
task_idn_install = result_sw_info[1].ToString();
task_idn_deinstall = result_sw_info[2].ToString();
indicator = result_sw_info[3].ToString();
parameter = result_sw_info[4].ToString();
string[] software_data = new string[] {sw_id, softwarename, task_idn_install, task_idn_deinstall, indicator, parameter };
softwarelist_insert.Add(software_data);
}
result_sw_info.Close();
}
所以在softwarelist_insert鍵從0開始。但我怎麼可以添加軟件數據與foreach中的關鍵software_id。因爲我想用software_id標識列表中的arrys。
當心你[SQL注入漏洞](http://stackoverflow.com/questions/332365/how-does-the-sql-injection-from-the-bobby-tables-xkcd-comic-work) –
是啊,這只是一個例子我找到。用於原始代碼pdo。 – mnlfischer
你需要將它放在一個數組中嗎?還是可以創建一個對象來保存軟件信息並擁有該列表 – owen79