Here's the problem, i'm trying to determine if the table is empty or not because if it's empty it will process the next transaction.
Code(Transaction)
Public Sub insCust()
i = dtgOnGoing.CurrentRow.Index
If dtgOnGoing.Rows(i).Cells.Item(0).Value = Nothing Then
Try
c = DataGridViewCustomer.CurrentRow.Index
dt = New DataTable
da = New MySqlDataAdapter("SELECT SUM(jobprice) from custsrv WHERE GROUP BY custName=@custName", sqlCon)
da.SelectCommand.Parameters.AddWithValue("@custName", DataGridViewCustomer.Item(0, c).Value)
da.Fill(dt)
sqlCon.Close()
total = DataGridViewCustomer.Item(2, c).Value
sqlCon.Open()
dt = New DataTable
da = New MySqlDataAdapter("INSERT INTO billing (`custName`, `totalAmt`) VALUES (@custName,@total)", sqlCon)
da.SelectCommand.Parameters.AddWithValue("@custName", DataGridViewCustomer.Item(0, c).Value)
da.SelectCommand.Parameters.AddWithValue("@totalAmt", total)
da.Fill(dt)
MessageBox.Show("Payment is proceeded", "XYZ Auto Repair Shop", MessageBoxButtons.OK, MessageBoxIcon.Information)
sqlCon.Close()
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
Else
MessageBox.Show("No Transaction, please try again", "XYZ Auto Repair Shop", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End Sub
The problem is like this: Object reference not set to an instance of an object. If so, how can i determine if its empty or not?