插入多个数据库行 [英] Insert in multiple database rows

查看:94
本文介绍了插入多个数据库行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在数据库行中插入值的按钮.我数据库中的每一行都代表一天.现在我想在7个数据库行或mybeast 2列中插入我的值.每行都有一个时隙,日期,ID和状态,如何将它们插入行中?

在下面检查我的代码

此代码使我只能插入一行.

I have a button that insert values in a database row. Each row in my database will represent a day. now i want to insert my values in 7 of my databse rows or mybe 2 aleast. each row has a time slot, date, ID, and status, how can i insert these in my rows?

Check my code below

This code alows me to insert only in a single row.

protected void btnSubmit_Click(object sender, EventArgs e)
{
    int empRecNumber;
    if (DatePicker.SelectedDate.ToShortDateString() == "1/1/0001")
    {
        MessageBox.Show("Please Choose date to view Employee Slots", "??", MessageBoxButtons.OK, MessageBoxIcon.Information);
    }
    else if(ddlEmployeeID.SelectedValue==".:Select Employee:.")
    {
        MessageBox.Show("Please Choose an employee", "??", MessageBoxButtons.OK, MessageBoxIcon.Information);
    }
    else
    {
        ddlEmployeeID_SelectedIndexChanged(sender, e);
        foreach (GridViewRow rowItem in grvSlots.Rows)
        {
            CheckBox chk = (CheckBox)(rowItem.Cells[0].FindControl("CheckBox1"));
            if (chk.Checked)
            {
                string slotName = (grvSlots.DataKeys[rowItem.RowIndex]["SlotName"].ToString());
                Session["date"] = DatePicker.SelectedDate.ToShortDateString();
                empRecNumber = Convert.ToInt32(Session["idnumber"]);
                const string status = "a";

                ClsAppointmentSlots slots = new ClsAppointmentSlots(slotName, Session["date"].ToString(), Convert.ToInt32(empRecNumber), status);
                MessageBox.Show(slotName + "\n" + Session["date"].ToString() + "\n" + Convert.ToInt32(empRecNumber)+ "\n" +status);
                systemBusinessLayer.setSlot(slots);
                chkAll_CheckedChanged(sender, e);
                chk.Checked = false;
            }
        }
    }
    else
    {
        System.Windows.Forms.MessageBox.Show("Sorry you can not an appointment slot for previous days");
    }
}

推荐答案

在调试器下运行它.您会发现问题的所在.
Run it under the debugger. You''ll find the problem.


这篇关于插入多个数据库行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆