列不属于表,但确实如此

时间:2016-10-05 19:06:23

标签: c# mysql listview

这是代码,DueDate和ID列不属于表,但它存在。另一列很好,只是两列得到了错误。求你帮帮我。

try
{
    conn.Open();
    MySqlDataAdapter sda = new MySqlDataAdapter(sql2, conn);
    DataTable dt = new DataTable();
    sda.Fill(dt);
    conn.Close();

    lvborrowed.Clear();
    for (int row = 0; row < dt.Rows.Count; row++)
    {
        ListViewItem lvi = new ListViewItem(dt.Rows[row]["FirstName"].ToString());
        lvi.SubItems.Add(dt.Rows[row]["LastName"].ToString());
        lvi.SubItems.Add(dt.Rows[row]["BookName"].ToString());
        lvi.SubItems.Add(dt.Rows[row]["Category"].ToString());
        lvi.SubItems.Add(dt.Rows[row]["DateBorrowed"].ToString());

        lvi.SubItems.Add(dt.Rows[row]["DueDate"].ToString());
        lvi.SubItems.Add(dt.Rows[row]["Time"].ToString());
        lvi.SubItems.Add(dt.Rows[row]["ID"].ToString());

        lvborrowed.Items.Add(lvi);


    }

    lvborrowed.FullRowSelect = true;
    lvborrowed.GridLines = true;
    lvborrowed.View = View.Details;

    lvborrowed.Columns.Add("First Name", 150, HorizontalAlignment.Left);
    lvborrowed.Columns.Add("Last Name", 150, HorizontalAlignment.Left);
    lvborrowed.Columns.Add("Name of Book", 100, HorizontalAlignment.Left);
    lvborrowed.Columns.Add("Category", 100, HorizontalAlignment.Left);

    lvborrowed.Columns.Add("Borrow Date", 100, HorizontalAlignment.Left);

    lvborrowed.Columns.Add("Date to be Returned", 150, HorizontalAlignment.Left);

    lvborrowed.Columns.Add("Borrow Time", 100, HorizontalAlignment.Left);
    lvborrowed.Columns.Add("ID", 0, HorizontalAlignment.Left);


}
catch (Exception en)
{
    MessageBox.Show("Error Showlv"+en);
}

0 个答案:

没有答案