I'm doing a todo list vb.net, I have 2 button name Complete and Execute, when the user press Complete, the interface will let user to choose which task has been executed, and the task is from table name todolist
and if the user press Execute on this task then it will do a copy to table name complete
. But every time I run the program it appear NullreferenceException, but I already create the table.
I wonder is there my logic thinking or the system? Can anyone tell me where is my mistake?
Here is my Execute button
Private Sub btnexecute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnexecute.Click
If inc <> -1 Then
Dim cb As New OleDb.OleDbCommandBuilder(daa)
cb.QuotePrefix = "["
cb.QuoteSuffix = "]"
Dim dsNewRow As DataRow
con.Open()
dsNewRow = dss.Tables("complete").NewRow() `exception occur`
dsNewRow.Item("Task") = txtitem.Text
dsNewRow.Item("description") = txtdescript.Text
dsNewRow.Item("Date of create") = dtptoday.Text
dsNewRow.Item("Date of execute") = dtpcomplete.Text
dss.Tables("complete").Rows.Add(dsNewRow)
MaxRows = MaxRows + 1
da.Update(dss, "complete")
con.Close()
MsgBox("Task has been executed, will be remove here and put in!")
`enable and disable button
btncomplete.Enabled = True
btnSave.Enabled = False
btnadd.Enabled = True
btnUpdate.Enabled = True
btnremove.Enabled = True
inc = 0
`navigate records
NavigateRecords()
End If
End Sub
Here is my complete button
Private Sub btncomplete_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncomplete.Click
btnSave.Enabled = False
btnadd.Enabled = False
btnUpdate.Enabled = False
btnremove.Enabled = False
btnexecute.Enabled = True
`call back the record from todolist table
NavigateRecords()
End Sub