It should look similart to this:
Imports system.data.oledb
Sub updateIt()
'declare all variables
'oledb connection here
strSQLQuery = "UPDATE [Fall] SET [event_date]=@EventDate, [event]=@Event, [event_time]=@EventTime, [location]=@Location WHERE ([Fall].[id] = @ID)"
objCommand = New OleDbCommand(strSQLQuery, objConn)
' Add parameters that our SQL update command needs:
objCommand.Parameters.Add(New OleDbParameter("@EventDate", OleDbType.Date, 25))
objCommand.Parameters("@EventDate").Value = txtEventDate.Text
objCommand.Parameters.Add(New OleDbParameter("@Event", OleDbType.VarChar, 100))
objCommand.Parameters("@Event").Value = txtEvent.Text
objCommand.Parameters.Add(New OleDbParameter("@EventTime", OleDbType.VarChar, 49))
objCommand.Parameters("@EventTime").Value = txtEventTime.Text
objCommand.Parameters.Add(New OleDbParameter("@Location", OleDbType.VarChar, 49))
objCommand.Parameters("@Location").Value = txtLocation.Text
intID = dgDates.DataKeys(e.Item.ItemIndex)
objCommand.Parameters.Add(New OleDbParameter("@ID", OleDbType.Integer))
objCommand.Parameters("@ID").Value = intID
' Open the connection, execute the command, and close the connection.
objConn.Open()
objCommand.ExecuteNonQuery()
objConn.Close()
End Sub
Notice that it is the parameters are in the exact order as the strSQL and the id field is the last parameter. If that doesn't do it you need to give write permissions to the aspnet user account on the folder that the db is in.
|