我正在尝试将数据加载到 Visual Basic 中的 datagridview 中,但出现此错误。
从“DBNull”类型到“Decimal”类型的转换无效。- Datagridview 从数据库加载数据时出现问题,
请在写回复时记住我是一个完整的新手。
顺便说一句,我尝试在某些 .ToString 的 Value 之后添加
Private Sub DataGridView1_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
Dim i As Integer
Me.TextBox1.Text = DataGridView1.Item(0, i).Value.ToString
Me.TextBox8.Text = DataGridView1.Item(1, i).Value.ToString
Me.TextBox9.Text = DataGridView1.Item(2, i).Value.ToString
Me.TextBox11.Text = DataGridView1.Item(3, i).Value.ToString
'valoren_code'
Me.TextBox3.Text = DataGridView1.Item(4, i).Value.ToString
Me.TextBox13.Text = DataGridView1.Item(5, i).Value.ToString
Me.TextBox15.Text = DataGridView1.Item(6, i).Value.ToString
Me.TextBox14.Text = DataGridView1.Item(7, i).Value.ToString
Me.NumericUpDown6.Value = DataGridView1.Item(8, i).Value.ToString
Me.DateTimePicker2.Text = DataGridView1.Item(9, i).Value.ToString
Me.ComboBox1.SelectedItem = DataGridView1.Item(10, i).Value.ToString
Me.ComboBox8.SelectedItem = DataGridView1.Item(11, i).Value.ToString
Me.ComboBox2.SelectedItem = DataGridView1.Item(12, i).Value.ToString
Me.ComboBox3.SelectedItem = DataGridView1.Item(13, i).Value.ToString
Me.ComboBox4.SelectedItem = DataGridView1.Item(14, i).Value.ToString
Me.ComboBox5.SelectedItem = DataGridView1.Item(15, i).Value.ToString
Me.ComboBox6.SelectedItem = DataGridView1.Item(16, i).Value.ToString
Me.ComboBox7.SelectedItem = DataGridView1.Item(17, i).Value.ToString
Me.ListBox1.SelectedItem = DataGridView1.Item(18, i).Value.ToString
Me.NumericUpDown8.Text = DataGridView1.Item(19, i).Value.ToString
Me.NumericUpDown7.Text = DataGridView1.Item(20, i).Value.ToString
Me.NumericUpDown5.Text = DataGridView1.Item(21, i).Value.ToString
Me.NumericUpDown13.Text = DataGridView1.Item(22, i).Value.ToString
Me.NumericUpDown14.Value = DataGridView1.Item(23, i).Value.ToString
'mid_trade_clean_price_proximity
Me.NumericUpDown15.Value = DataGridView1.Item(24, i).Value.ToString
Me.NumericUpDown16.Value = DataGridView1.Item(25, i).Value
Me.TextBox2.Text = DataGridView1.Item(26, i).Value.ToString
Me.ListBox3.SelectedItem = DataGridView1.Item(27, i).Value.ToString
End Sub