Sub CboSO_DropDown(ByVal sender As Object, ByVal e As System.EventArgs) Handles CboSO.DropDown
If functionmode = "UPDATE" Then
Dim daProp2 As New OdbcDataAdapter()
Dim dsProp2 As New DataSet()
Dim qryProp2 As String
qryProp2 = "SELECT * FROM so WHERE scn = '" & txtSCN.Text & " 'AND shutout_ind <> 'N' and so.reload_ind='N' and so.redelv_ind='N'"
daProp2.SelectCommand = New OdbcCommand(qryProp2, conn)
Dim cb2 As OdbcCommandBuilder = New OdbcCommandBuilder(daProp2)
daProp2.Fill(dsProp2, "so")
Dim dtRbt As DataTable = dsProp2.Tables("so")
If dsProp2.Tables(0).Rows.Count > 0 Then
CboSO.DataSource = dtRbt
CboSO.DisplayMember = "so_num"
End If
End If
End Sub
Private Sub CboSO_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles CboSO.KeyPress
Dim daProp3 As New OdbcDataAdapter()
Dim dsProp3 As New DataSet()
Dim qryProp3 As String
qryProp3 = "SELECT SUM(item_num) as totitemnum FROM soitem WHERE scn= '" & txtSCN.Text & " 'AND so_num='" & CboSO.SelectedItem & "' "
daProp3.SelectCommand = New OdbcCommand(qryProp3, conn)
Dim cb3 As OdbcCommandBuilder = New OdbcCommandBuilder(daProp3)
daProp3.Fill(dsProp3, "soitem")
Dim dtRbt As DataTable = dsProp3.Tables("soitem")
If dsProp3.Tables(0).Rows.Count > 0 Then
LblSOQty.Text = IIf(IsDBNull(dsProp3.Tables(0).Rows(0)("totitemnum")), "", dsProp3.Tables(0).Rows(0)("totitemnum"))
End If
End Sub
答案 0 :(得分:0)
您必须使用CboSO.SelectedValue
或CboSO.Text
属性而不是Cbo.SelectedItem
。
PS:使用参数(prepare)代替硬编码的sql字符串。