数据库值未显示在vb.net的组合框中

时间:2014-07-16 08:49:04

标签: vb.net combobox

    Try


        sqlstr = "select lti_no,loc_code,to_loc,issue_Date,status,supplier_code,remarks,total_pack,total_loose from pos_lti_out_hdr where lti_no='" & srch & "'"

        Dim da As SqlClient.SqlDataAdapter
        Dim searchresult As New DataTable
        Dim DS As DataSet
        da = New SqlClient.SqlDataAdapter(sqlstr, AppsCon)
        da.Fill(searchresult)
        If searchresult.Rows.Count <> 0 Then
            txtfrmlocation.Text = searchresult.Rows(0)("loc_code").ToString
            txtremarks.Text = searchresult.Rows(0)("remarks").ToString
            txttransferdate.Text = searchresult.Rows(0)("issue_date").ToString
            cmbtolocation.Text = searchresult.Rows(0)("to_loc").Tostring
            cmbstatus.Text = searchresult.Rows(0)("status").ToString
            txttotalqty.Text = searchresult.Rows(0)("total_pack").ToString
            txttotalloose.Text = searchresult.Rows(0)("total_loose").ToString

上面的代码从数据库中检索值,但不会将所选记录的数据绑定到组合框。组合框仅显示空白值。在调试模式下,列的数据集中有值,但在组合框中不显示。 我不知道我做错了什么。数据库中的字段是to_loc。我还将附加调试代码,因为它只显示零项。但是在数据集中它的存在。enter image description here enter image description here

1 个答案:

答案 0 :(得分:0)

更改组合框的下拉样式以下拉解决问题。 风格是下拉列表。