Editable data grid view?
-
Hello everyone I want a fully editable, DB interacted data grid view. By some mystake, the system has multiple DB's and I cannot use the interface. I have to enter the code to call a table from a specific database, I don't ask how can I fix this, we got along together well until now :) I made this data grid view editable, that user can add rows and edit info on the table. My questions are -How can I call a table from database to view in this grid view -How can I save the table's final state? (this is a single usered non-online system so performance is not issue, I can appreciate a solution that drops the previous table and creates a new one with the edited data grid view) Thank you
-
Hello everyone I want a fully editable, DB interacted data grid view. By some mystake, the system has multiple DB's and I cannot use the interface. I have to enter the code to call a table from a specific database, I don't ask how can I fix this, we got along together well until now :) I made this data grid view editable, that user can add rows and edit info on the table. My questions are -How can I call a table from database to view in this grid view -How can I save the table's final state? (this is a single usered non-online system so performance is not issue, I can appreciate a solution that drops the previous table and creates a new one with the edited data grid view) Thank you
-How can I call a table from database to view in this grid view
SqlDataAdapter SQL\_Adapter; DataTable dtReport1 = new DataTable(); string SQL\_Command = "SQL STATEMENT GOES HERE" //if (cklbxColumns.Items.Count != 0) //{ SQL\_Command += "'" + strExecutive + "', '" + strToolClass + "'"; //} try { using (SQL\_Conn = new SqlConnection(WhatIsTheSQLConnectionString)) { if (SQL\_Conn.State != ConnectionState.Open) { SQL\_Conn.Open(); } else { SQL\_Conn.Close(); SQL\_Conn.Open(); } //using (SQL\_Adapter = new SqlDataAdapter("SQL STATEMENT GOES HERE", SQL\_Conn)) using (SQL\_Adapter = new SqlDataAdapter(SQL\_Command, SQL\_Conn)) { // Use DataAdapter to fill DataTable SQL\_Adapter.Fill(dtReport1); // 4 // Render data onto the screen // dgvReport = DataGridViewer dgvReport.DataSource = dtReport1; //dgvReport.DataMember = "dtToolStatusboardReport"; dgvReport.Refresh(); gbToolStatusBoard.Refresh(); //ActiveForm.Refresh(); } SQL\_Adapter.Dispose(); } SQL\_Conn.Close(); } catch { return; }
-How can I save the table's final state? (this is a single usered non-online system so performance is not issue, I can appreciate a solution that drops the previous table and creates a new one with the edited data grid view) For this method you would simply export the datatable directly back to the main table after flushing out the data in the origional table.
-
-How can I call a table from database to view in this grid view
SqlDataAdapter SQL\_Adapter; DataTable dtReport1 = new DataTable(); string SQL\_Command = "SQL STATEMENT GOES HERE" //if (cklbxColumns.Items.Count != 0) //{ SQL\_Command += "'" + strExecutive + "', '" + strToolClass + "'"; //} try { using (SQL\_Conn = new SqlConnection(WhatIsTheSQLConnectionString)) { if (SQL\_Conn.State != ConnectionState.Open) { SQL\_Conn.Open(); } else { SQL\_Conn.Close(); SQL\_Conn.Open(); } //using (SQL\_Adapter = new SqlDataAdapter("SQL STATEMENT GOES HERE", SQL\_Conn)) using (SQL\_Adapter = new SqlDataAdapter(SQL\_Command, SQL\_Conn)) { // Use DataAdapter to fill DataTable SQL\_Adapter.Fill(dtReport1); // 4 // Render data onto the screen // dgvReport = DataGridViewer dgvReport.DataSource = dtReport1; //dgvReport.DataMember = "dtToolStatusboardReport"; dgvReport.Refresh(); gbToolStatusBoard.Refresh(); //ActiveForm.Refresh(); } SQL\_Adapter.Dispose(); } SQL\_Conn.Close(); } catch { return; }
-How can I save the table's final state? (this is a single usered non-online system so performance is not issue, I can appreciate a solution that drops the previous table and creates a new one with the edited data grid view) For this method you would simply export the datatable directly back to the main table after flushing out the data in the origional table.
oh thank you, I'll give it a try