J
junglist
Hi guys,
I've been trying to implement an editable datagrid and i have been
succesful up to the point where i can update my datagrid row by row.
However what used to happen was that once i updated one row, all of
them were updated so i immediatelly figured out that i have to include
the id of every entry in the update statement. This is where the
problem is raised. My database is an Access database. The table i am
updating contains a Date field which is filled in by the Now()
function Access provides, which inserts the current date and time. I
believe that is what creates the problem. I don't know how to update
the the Date field in my UPDATE statement. Can you please help? I've
included my sub.
Thank you in advance
Public Sub grid_Update(sender As Object, e As
DataGridCommandEventArgs)
Dim strUnits As String = CType(e.Item.FindControl( "txtUnits"),
TextBox).Text
Dim strid As String = CType(e.Item.FindControl( "ID"), Label).Text
' Dim strid As Integer =
Convert.ToInteger(e.Item.Cells[1].Controls[0].Text)
' Dim strid as String = "36"
' test.text = strid
DBConnection = New OleDbConnection(strconnect)
DBcommand=New OleDbCommand
DBcommand.commandtext="Update holding set units='" + strUnits +"'
where holdid = '" + strid + "' ;"
Dbcommand.commandtype=commandtype.Text
Dbcommand.connection=dbconnection
DBConnection.Open()
DBCommand.ExecuteNonQuery()
DBConnection.Close()
grid.EditItemIndex = -1
BindData()
End Sub
I've been trying to implement an editable datagrid and i have been
succesful up to the point where i can update my datagrid row by row.
However what used to happen was that once i updated one row, all of
them were updated so i immediatelly figured out that i have to include
the id of every entry in the update statement. This is where the
problem is raised. My database is an Access database. The table i am
updating contains a Date field which is filled in by the Now()
function Access provides, which inserts the current date and time. I
believe that is what creates the problem. I don't know how to update
the the Date field in my UPDATE statement. Can you please help? I've
included my sub.
Thank you in advance
Public Sub grid_Update(sender As Object, e As
DataGridCommandEventArgs)
Dim strUnits As String = CType(e.Item.FindControl( "txtUnits"),
TextBox).Text
Dim strid As String = CType(e.Item.FindControl( "ID"), Label).Text
' Dim strid As Integer =
Convert.ToInteger(e.Item.Cells[1].Controls[0].Text)
' Dim strid as String = "36"
' test.text = strid
DBConnection = New OleDbConnection(strconnect)
DBcommand=New OleDbCommand
DBcommand.commandtext="Update holding set units='" + strUnits +"'
where holdid = '" + strid + "' ;"
Dbcommand.commandtype=commandtype.Text
Dbcommand.connection=dbconnection
DBConnection.Open()
DBCommand.ExecuteNonQuery()
DBConnection.Close()
grid.EditItemIndex = -1
BindData()
End Sub