Saving Modified Column Value in Datagridview to Database
-
hi there, i have a datagridview controls that gets its data from database, i want to edit (modify) some rows and send back the modified content of all rows that are found under the same column to databases. Any help? Thank u in advance
It is actually quicker and easier to try a search[^] before posting a question. This probably ranks as one of the most asked questions in the forums.
Never underestimate the power of human stupidity RAH
-
It is actually quicker and easier to try a search[^] before posting a question. This probably ranks as one of the most asked questions in the forums.
Never underestimate the power of human stupidity RAH
would help me with it plz, my code under save button is this? thank u in adnvance For i As Integer = 0 To DataGridView1.Rows.Count - 1 'DataGridView1(3, i) Try c.cmd = New SqlCommand("update courseregistered set lettergrade='" & DataGridView1(3, i).Value.ToString & "' where courseno='" & (ComboBox1.SelectedItem.ToString).Substring(0, 7) & "' and studid='" & DataGridView1.SelectedCells(i).Value.ToString & "'", c.cn) c.cmd.CommandType = CommandType.Text c.cmd.ExecuteNonQuery() Catch ex As NullReferenceException MsgBox(ex.Message) End Try Next c.da.Update(c.ds, "courseregistered") MsgBox("update has been succesful") it will save the last row under the column and display "update successful" message but ignores other rows in the column
-
would help me with it plz, my code under save button is this? thank u in adnvance For i As Integer = 0 To DataGridView1.Rows.Count - 1 'DataGridView1(3, i) Try c.cmd = New SqlCommand("update courseregistered set lettergrade='" & DataGridView1(3, i).Value.ToString & "' where courseno='" & (ComboBox1.SelectedItem.ToString).Substring(0, 7) & "' and studid='" & DataGridView1.SelectedCells(i).Value.ToString & "'", c.cn) c.cmd.CommandType = CommandType.Text c.cmd.ExecuteNonQuery() Catch ex As NullReferenceException MsgBox(ex.Message) End Try Next c.da.Update(c.ds, "courseregistered") MsgBox("update has been succesful") it will save the last row under the column and display "update successful" message but ignores other rows in the column
:sigh: What error message are you getting? What is c as in
c.cmd = new
etcDambod wrote:
c.da.Update(c.ds, "courseregistered")
What do you expect this to do, dammed stoopid MS wizarded crap, why people can't use a proper DAL I don't know.
Never underestimate the power of human stupidity RAH
-
:sigh: What error message are you getting? What is c as in
c.cmd = new
etcDambod wrote:
c.da.Update(c.ds, "courseregistered")
What do you expect this to do, dammed stoopid MS wizarded crap, why people can't use a proper DAL I don't know.
Never underestimate the power of human stupidity RAH
-
c is the class where the dataAdpater and dataset are declared and set. it says "Obect reference not set to an instance of an object
try adding this to the start of the method
c = new classname()
Never underestimate the power of human stupidity RAH
-
try adding this to the start of the method
c = new classname()
Never underestimate the power of human stupidity RAH
-
c is the class where the dataAdpater and dataset are declared and set. it says "Obect reference not set to an instance of an object