Tag: delete row

“无法通过行访问”已删除的行信息“尝试从我的数据表中删除未使用的行

我正在抓取数据,将其粘贴到DataTable ,并将其显示在绑定到该表的DataGridView中。 我试图这样做,以便删除当前抓取中未包含的数据表中的数据。 我这样做如下: public void FillTable(DataTable table, IEnumerable readings) { var currentReadingsNames = new List(); var lastParent = string.Empty; var index = 0; foreach (var reading in readings) { if (reading.ParentName != lastParent) { lastParent = reading.ParentName; index = 0; } LoadRow(table, reading, index++); currentReadingsNames.Add(MakeKey(reading)); } //Iterate through the rows in our data table. […]

从SQL Server表中删除一行

我试图使用按钮事件从我的SQL Server数据库表中删除一整行。 到目前为止,我的尝试都没有成功。 这就是我想要做的: public static void deleteRow(string table, string columnName, string IDNumber) { try { using (SqlConnection con = new SqlConnection(Global.connectionString)) { con.Open(); using (SqlCommand command = new SqlCommand(“DELETE FROM ” + table + ” WHERE ” + columnName + ” = ” + IDNumber, con)) { command.ExecuteNonQuery(); } con.Close(); } } catch (SystemException […]

如何从datagridview和数据库中删除选定的行

我们的想法是,删除时选择的行将从datagridview,数据库中删除,然后datagridview将被刷新。 我假设它必须用SQL完成,但是如何将类型为text的sqlcommand与该特定行的删除代码相关联? 数据库由一个表组成,数据网格绑定到该表。 删除按钮: private void btnBookRecord_Click(object sender, EventArgs e) { if (this.BooksGrid.SelectedRows.Count > 0) { foreach (DataGridViewRow dgvrCurrent in BooksGrid.SelectedRows) { if (dgvrCurrent == BooksGrid.CurrentRow) { BooksGrid.CurrentCell = null; } // Delete row code here } } }

为什么我无法在Method中访问数据?

我目前正在尝试通过如下方法填充TableLayoutPanel : private int _rowCount; public void InitPaths() { int c = 1; int a = 1; while (a < _PathRows.Length – 1) { var label = new Label(); // // Label – Format. // label.Dock = DockStyle.Fill; label.AutoSize = false; label.Text = _pfadZeilen[a]; label.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; label.Size = new System.Drawing.Size(22, 13); label.BackColor = System.Drawing.Color.Transparent; […]

在C#中删除2D字符串数组的行

我正在制作一个将数据存储在2D数组中的程序。 我希望能够从这个数组中删除行。 我无法弄清楚为什么这段代码不起作用: for (int n = index; n < a.GetUpperBound(1); ++n) { for (int i = 0; i < a.GetUpperBound(0); ++i) { a[i, n] = a[i, n + 1]; } } 有人可以帮帮我吗? 我希望它删除一行并将其下面的所有行拖放到一个地方。 谢谢!

如何从GridView中删除一行?

我在asp.net 2005 c#中使用GridView控件。 如何从GridView删除特定行。 我写了以下代码。 但它不起作用…… DataRow dr = dtPrf_Mstr.NewRow(); dtPrf_Mstr.Rows.Add(dr); GVGLCode.DataSource = dtPrf_Mstr; GVGLCode.DataBind(); int iCount = GVGLCode.Rows.Count; for (int i = 0; i <= iCount; i++) { GVGLCode.DeleteRow(i); } GVGLCode.DataBind();