This may have been asked before but I could not find exactly what I am searching for.
I have a form which has a dropdown for job titles. Based on the selection in the dropdown, 2 listboxes are populated with items that those roles receive for hardware and software resources. The listboxes are populated by a table called dbo.RoleResources
.
In the code behind of my asp form I am needing to save the details of the form to another SQL Server table. I am using a stored procedure that inserts the details into a table called dbo.NewHireReources
. For most I can use
SqlCmd.Parameters.Add(@EmployeeName, SqlDbType.NVarChar, 255).Value = txtEmployeeName.Text;
However, I need to get all items in the listboxes to go into a column named Hardware
and a column named Software
.
I have tried the code shown below, but it is not working effectively as it says too many arguments defined in stored procedure even though all other parameters are commented out at the moment.
foreach (ListItem item in hardwareList.Items)
{
SqlCmd.Parameters.Clear();
SqlCmd.Parameters.AddWithValue("@Hardware", item.Value);
}
What is the best way to get all items into the table? Can I just call a select statement and pull in the list from dbo.RoleResources
? Any help is appreciated.