这是问题,我正在尝试确定表是否为空,因为如果它是空的,它将处理下一个事务。
码(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
问题是这样的:对象引用未设置为对象的实例。 如果是这样,我怎样才能确定它是否为空?