b001
asked on
Sql Update
Hi Experts
I use the following code to change some fields
CS.Open()
DA.Fill(DS, "Codes")
count = grid3.Rows.Count
For X = 1 To 30 - count
Dim newCustomersRow As DataRow = DS.Tables("Codes").NewRow( )
newCustomersRow("Prefix") = "M"
newCustomersRow("a3") = GroupBox.Text
newCustomersRow("a10") = "@" + GroupBox.Text + "@@"
newCustomersRow("KeyCode") = KeycodeMax.Text + X
newCustomersRow("SubKey1") = "0"
DS.Tables("Codes").Rows.Ad d(newCusto mersRow)
Next
dt = DS.Tables("codes")
dt.DefaultView.RowFilter = "a3 ='" & GroupBox.Text & "'"
grid1.DataSource = dt
When I use foloowing code to update
CS.Open()
cmdBuilder = New SqlCommandBuilder(DA)
DA.Update(DS, "Codes")
MsgBox("Changes Saved")
It updates all the rows from Grid1 except the first row, where the pointer is.
If I move the pointer in the grid1 to second row then Update, it updates all the rows.
I would like to update all the rows without moving the pointer in the grid1.
Please help
I use the following code to change some fields
CS.Open()
DA.Fill(DS, "Codes")
count = grid3.Rows.Count
For X = 1 To 30 - count
Dim newCustomersRow As DataRow = DS.Tables("Codes").NewRow(
newCustomersRow("Prefix") = "M"
newCustomersRow("a3") = GroupBox.Text
newCustomersRow("a10") = "@" + GroupBox.Text + "@@"
newCustomersRow("KeyCode")
newCustomersRow("SubKey1")
DS.Tables("Codes").Rows.Ad
Next
dt = DS.Tables("codes")
dt.DefaultView.RowFilter = "a3 ='" & GroupBox.Text & "'"
grid1.DataSource = dt
When I use foloowing code to update
CS.Open()
cmdBuilder = New SqlCommandBuilder(DA)
DA.Update(DS, "Codes")
MsgBox("Changes Saved")
It updates all the rows from Grid1 except the first row, where the pointer is.
If I move the pointer in the grid1 to second row then Update, it updates all the rows.
I would like to update all the rows without moving the pointer in the grid1.
Please help
You are only inserting rows right? Do you mean it does not insert the first added row?
ASKER
HI CodeCruiser:
I only insert rows if the count is less than 30.
The first row is always exist.
It does not update if the pointer is on the first row in the grid.
I only insert rows if the count is less than 30.
The first row is always exist.
It does not update if the pointer is on the first row in the grid.
>I only insert rows if the count is less than 30.
>It does not update
Do you change some values as well? Programmatically?
>It does not update
Do you change some values as well? Programmatically?
ASKER
Yes . I do make changes to all rows Programmtically.
Hmm. You can change the selectedindex of the grid programmatically as well. Try with that and see if it updates the changes.
ASKER
Hi CodeCruiser:
Please write the code for me.
Thnaks
Please write the code for me.
Thnaks
Grid1.SelectedIndex = 1
ASKER
I have the following error
'SelectedIndex' is not a not a member of 'System.Windows.Forms.Data GridView'
'SelectedIndex' is not a not a member of 'System.Windows.Forms.Data
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.