如何将数据从一个数据表传输到另一个数据表

时间:2017-06-14 06:09:32

标签: c# asp.net visual-studio-2015 datatable

我正在尝试传输数据,当我点击跳过按钮时,数据将移动到另一个表中。我不确定如何编码它从队列表转移到missedQueue表。请帮忙:(

这是我的代码:

protected void BtnSkip_Click(object sender, EventArgs e)
    {
        ActivityTimer.Enabled = false;
        BtnSkip.Enabled = true;
        string timeCurrent = DateTime.Now.ToString("HH:mm:ss");
        string sql13 = "UPDATE queue SET status_id = 6, serve_status = 'Missed', queue_time = '{0}'" //Update Status ID, Serve Status, Queue Time
                              + " WHERE number = '{1}'";
        string sql = "SELECT name, p.nric, number, prescription_id FROM patient p, queue q" + " WHERE p.nric = q.nric AND status_id = 7 ORDER BY q.queue_time";
        DataSet dsR = DBMgr.GetDataSet(sql);
        try
        {
            sql13 = String.Format(sql13, timeCurrent, int.Parse(dsR.Tables[0].Rows[0]["number"].ToString()));
            if (DBMgr.ExecuteSQL(sql13) == 1)
            {
                LtlMsg.Text = "Missed!";
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
    }

1 个答案:

答案 0 :(得分:0)

如果要传输行,则应执行

之类的查询
INSERT INTO missedQueue(...) SELECT (...) from queue where number '{0}'

你应该从队列中删除行(如果需要,可以更新)