Kenneth Johansen
New member
Hi all,
I have a problem with updating data in the database.
When i click the button that fires the update function, it updates all but the selected row.. howcome?
Dim ds As New DataSet
Dim da As SqlDataAdapter
Sub fillGrid()
Dim sqlstr as string = "select ........"
Dim sqlcmd As New SqlCommand(sqlstr, _f.oConn)
Dim sqlcmdCount As New SqlCommand(sqlstrCount, _f.oConn)
With sqlcmd.Parameters
.Add("@Year", SqlDbType.Int).Value = CInt(Aar)
.Add("@Week", SqlDbType.Int).Value = CInt(Uge)
End With
da = New SqlDataAdapter(sqlcmd)
da.Fill(ds, "tbl_dataentry_test")
dgwData.DataSource = ds.Tables(0)
End Sub
Sub UpdateData()
Dim cmdbuilder As New SqlCommandBuilder(da)
Dim changes As DataSet = ds.GetChanges
If changes IsNot Nothing Then
Dim i As Integer
i = da.Update(ds, "tbl_dataentry_test")
MessageBox.Show("Records Updated= " & i)
End If
End Sub
I have a problem with updating data in the database.
When i click the button that fires the update function, it updates all but the selected row.. howcome?
Dim ds As New DataSet
Dim da As SqlDataAdapter
Sub fillGrid()
Dim sqlstr as string = "select ........"
Dim sqlcmd As New SqlCommand(sqlstr, _f.oConn)
Dim sqlcmdCount As New SqlCommand(sqlstrCount, _f.oConn)
With sqlcmd.Parameters
.Add("@Year", SqlDbType.Int).Value = CInt(Aar)
.Add("@Week", SqlDbType.Int).Value = CInt(Uge)
End With
da = New SqlDataAdapter(sqlcmd)
da.Fill(ds, "tbl_dataentry_test")
dgwData.DataSource = ds.Tables(0)
End Sub
Sub UpdateData()
Dim cmdbuilder As New SqlCommandBuilder(da)
Dim changes As DataSet = ds.GetChanges
If changes IsNot Nothing Then
Dim i As Integer
i = da.Update(ds, "tbl_dataentry_test")
MessageBox.Show("Records Updated= " & i)
End If
End Sub