运算符'+'未定义为'Decimal'类型并输入'DBNull'

时间:2017-02-20 18:46:49

标签: vb.net oracle10g

我正在努力在我的数据网格中显示数据,并显示textbox2中带来的项目总数,但此错误“运算符'+'未定义为类型'十进制'并键入'DBNull'。”问题是什么?请帮助我,我需要完成这个非常糟糕的事情。 :(

Private Sub dailySales_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    con.Connect()
    DataGridView1.DataSource = dtb
    dtb.Columns.Add("Transaction Code")
    dtb.Columns.Add("Transaction Date ")
    dtb.Columns.Add("Item Code")
    dtb.Columns.Add("Item")
    dtb.Columns.Add("Description")
    dtb.Columns.Add("Quantity")
    dtb.Columns.Add("Price")
    dtb.Columns.Add("Total")
    display()
    con.Close()
    total()
    TextBox1.Text = DataGridView1.RowCount()
    Me.DataGridView1.DefaultCellStyle.Font = New Font("Cambria", 10)
    Me.DataGridView1.ColumnHeadersDefaultCellStyle.Font = New Font("Cambria", 12)
    Me.DataGridView1.DefaultCellStyle.SelectionBackColor = Color.FromArgb(129, 207, 224)
    Dim i As Integer
    For i = 0 To DataGridView1.Columns.Count - 1
        DataGridView1.Columns.Item(i).SortMode = DataGridViewColumnSortMode.Programmatic
    Next
End Sub
Sub total()
    Dim sum As Decimal = 0
    For x = 0 To DataGridView1.Rows.Count - 1
        sum =sum +  DataGridView1.Rows(x).Cells(7).Value
    Next
    TextBox2.Text = sum
End Sub
Sub display()
    con.Connect()
    Label6.Text = Date.Now.ToString("dd MMMM yyyy")
    Dim da = Label6.Text
    Dim sc = " where lower(tns_date) like lower('%" & da & "%') "
    Dim sql = "select * from tns " & sc & " order by tns_code desc"
    odr = con.Retrieve(sql)
    dtb.Clear()
    While (odr.Read)
        Dim ic = odr.GetOracleValue(0)
        Dim itn = odr.GetOracleValue(1)
        Dim de = odr.GetOracleValue(2)
        Dim ca = odr.GetOracleValue(3)
        Dim pr = odr.GetOracleValue(4)
        Dim st = odr.GetOracleValue(5)
        Dim sst = odr.GetOracleValue(6)
        dtb.Rows.Add(ic, itn, de, ca, pr, st, sst)
    End While
    con.Close()

End Sub

1 个答案:

答案 0 :(得分:0)

像这样测试。

String input = "";
do {
    // Your code here
    System.out.println("Continue?");
    input = MyScanner.next();
} while (!input.equals("exit");