1
Answer

recording multiple checkedlist box items in database

Sianny Squire

Sianny Squire

17y
2k
1

HI all,

I have tried asking on other forums but I get very short answers but I would love for someone to maybe look at my code and change the exact areas where I am wrong.

I have a table called empSkills which has employeeID pk and technicalSkillsID fk, a Technicalskills table with TechnicalskillsID pk and technicalskills, and employee table with empid pk and all other IDs etc.  The Empskills table allows for multiple skills to be setsaved against an employee. at the moment I am not able to do this though. I heard about list collection or something but can someone possibly show me exactly how I do this? I have been trying to find the answer for a week so you can see that I'm not going to get it on my own. I've left the commented parts in so you can see what I've tried.

<code>

 

Thank you so so much.. !!!!

 Sianny

if (adoDR.HasRows)

{

while (adoDR.Read())

{

//techSkillsCheckListBox2.SelectedItems.Equals(adoDR["TechnicalSkillsID"]);

 

if (techSkillsCheckListBox2.CheckedItems.Count != 0)

{

for (int x = 0; x <= techSkillsCheckListBox2.CheckedItems.Count - 1; x++)

{

if (techSkillsCheckListBox2.CheckedItems[x].Equals(TechnicalSkills))

{

sql = "Insert into EmpSkills(EmployeeID,TechnicalSkillsID) values ('" + this.EmployeeID + "','" + techSkillsCheckListBox2.CheckedItems.ToString() + "')";

// for(i = 0; i< (techSkillsCheckListBox2.Items.Count); i++)

// {

// if (techSkillsCheckListBox2.CheckedItems.Equals(TechnicalSkill))

 

// foreach (int i in techSkillsCheckListBox2.CheckedIndices)

// foreach (object itemChecked in techSkillsCheckListBox2.CheckedItems)

// {

// sql = "Insert into EmpSkills(EmployeeID,TechnicalSkillsID) values ('" + this.EmployeeID + "','" + techSkillsCheckListBox2.CheckedItems.ToString() + "')";

 

</code>

Answers (1)