dmenke 0 Newbie Poster

I am running multiple lines generated from a SQL data source and using pulldown menus to input the data on a button click control using c#.

When this is executed with the button, only the first set of data is transferred to the SQL table. The other lines are not transferred at all.

Am I missing something to make all the data transfer over?

public void RelationshipInsert(string Date, string Area, string Supervisor, string Functions, string SubFuncArea,
                                       string SubFuncPrin, string SubFuncAct, string SubFuncLOO, string Dispatcher,
                                       string DStartTime, string DEndTime, string Additional_Information)
        {
            SqlConnection DISP = new SqlConnection(ConfigurationManager.ConnectionStrings["DispatchConnectionString"].ConnectionString);
            SqlCommand DISP_cmd = new SqlCommand("spDispatchRelationInsert", DISP);
            DISP_cmd.CommandType = CommandType.StoredProcedure;

            DISP_cmd.Parameters.Add(new SqlParameter("@Date", Date));
            DISP_cmd.Parameters.Add(new SqlParameter("@Area", Area));
            DISP_cmd.Parameters.Add(new SqlParameter("@Supervisor",Supervisor));
            //DISP_cmd.Parameters.Add(new SqlParameter("@StartTime", StartTime));
            //DISP_cmd.Parameters.Add(new SqlParameter("@EndTime", EndTime));
            DISP_cmd.Parameters.Add(new SqlParameter("@Functions", Functions));
            DISP_cmd.Parameters.Add(new SqlParameter("@SubFuncArea", SubFuncArea));
            DISP_cmd.Parameters.Add(new SqlParameter("@SubFuncPrin", SubFuncPrin));
            DISP_cmd.Parameters.Add(new SqlParameter("@SubFuncAct", SubFuncAct));
            DISP_cmd.Parameters.Add(new SqlParameter("@SubFuncLOO", SubFuncLOO));
            DISP_cmd.Parameters.Add(new SqlParameter("@Dispatcher", Dispatcher));
            DISP_cmd.Parameters.Add(new SqlParameter("@DStartTime", DStartTime));
            DISP_cmd.Parameters.Add(new SqlParameter("@DEndTime", DEndTime));
            DISP_cmd.Parameters.Add(new SqlParameter("@Additional_Information", Additional_Information));
            try
            {
                DISP.Open();
                DISP_cmd.ExecuteNonQuery();
            }
            catch (Exception no_data)          
            {
                Label1.Text = no_data.Message;
            }
            finally
            {
                DISP.Close();
                DISP.Dispose();
                DISP_cmd.Dispose();
            }    
        }

        

        protected void Button1_Click(object sender, EventArgs e)
        {
            if (DropDownList11.SelectedIndex > 0)
            {
                RelationshipInsert(Calendar1.SelectedDate.ToString(),
                                   DropDownList10.SelectedValue.ToString(),
                                   DropDownList1.SelectedValue.ToString(),
                                   DropDownList14.SelectedValue.ToString(),
                                   DropDownList15.SelectedValue.ToString(),
                                   DropDownList16.SelectedValue.ToString(),
                                   DropDownList17.SelectedValue.ToString(),
                                   DropDownList18.SelectedValue.ToString(),
                                   DropDownList11.SelectedValue.ToString(),
                                   DropDownList12.SelectedValue.ToString(),
                                   DropDownList13.SelectedValue.ToString(),
                                   TextBox1.Text.ToString());
            }

            Label1.Text = DropDownList19.SelectedIndex.ToString();

            if (DropDownList19.SelectedIndex > 0)
            {
                RelationshipInsert(Calendar1.SelectedDate.ToString(),
                                   DropDownList10.SelectedValue.ToString(),
                                   DropDownList1.SelectedValue.ToString(),
                                   DropDownList22.SelectedValue.ToString(),
                                   DropDownList23.SelectedValue.ToString(),
                                   DropDownList24.SelectedValue.ToString(),
                                   DropDownList25.SelectedValue.ToString(),
                                   DropDownList26.SelectedValue.ToString(),
                                   DropDownList19.SelectedValue.ToString(),
                                   DropDownList20.SelectedValue.ToString(),
                                   DropDownList21.SelectedValue.ToString(),
                                   TextBox2.Text.ToString());
            }

            if (DropDownList27.SelectedIndex > 0)
            {
                RelationshipInsert(Calendar1.SelectedDate.ToString(),
                                   DropDownList10.SelectedValue.ToString(),
                                   DropDownList1.SelectedValue.ToString(),
                                   DropDownList30.SelectedValue.ToString(),
                                   DropDownList31.SelectedValue.ToString(),
                                   DropDownList32.SelectedValue.ToString(),
                                   DropDownList33.SelectedValue.ToString(),
                                   DropDownList34.SelectedValue.ToString(),
                                   DropDownList27.SelectedValue.ToString(),
                                   DropDownList28.SelectedValue.ToString(),
                                   DropDownList29.SelectedValue.ToString(),
                                   TextBox3.Text.ToString());
            }
        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.