【发布时间】:2016-05-02 17:25:46
【问题描述】:
在我的 VB 表单中,我使用有界数据网格视图来管理我的数据库表。我使用 2 个参数创建 FillBy() 查询: int1, int2 。两者都是整数。
当某些控件发生更改时,我调用 sub Anychange() 以触发 FillByToolStipButton_Click。但是这两个参数好像没变,Sub FillByToolStipButton_Click出现错误信息:“Conversion from string "" to type integer is not valid"
请指教。谢谢。
下面是我的代码的某些部分
Private Sub FillByToolStripButton_Click(sender As Object, e As EventArgs) Handles FillByToolStripButton.Click
Try
Me.Before_CloseTableAdapter.FillBy(Me.BeforeCloseDataSet.Before_Close, CType(int1ToolStripTextBox.Text, Integer), CType(int2ToolStripTextBox.Text, Integer))
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show("Fillby - " + ex.Message)
End Try
End Sub
Private Sub AnyChanged()
Try
int1StripTextBox.Text = CType(ComboBox1.SelectedValue, String)
int2ToolStripTextBox.Text = CType(ComboBox2.SelectedValue, String)
FillByToolStripButton_Click(Nothing, Nothing)
Catch ex As Exception
MsgBox("AnyChanged - " + ex.Message)
End Try
End Sub
【问题讨论】:
-
哪一行导致错误?
-
你确定文本框中有正确的输入(只有整数,没有小数点)?
标签: vb.net datagridview ctype