简体   繁体   中英

Issue with displaying SQL result in DataGridView

I am trying to show the results of a SQL query within a data grid view on my application. The following code is what i have written but it dosent seem to matter what i do, i cannot get any display in the datagridview on my form. Can anyone point me in the right direction?

code:

    Sql = "SELECT * FROM jobList WHERE techID = " & TechScreenID & ""

    connection = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source =   C:\Users\Dave\Documents\joblist.mdb;"
    con.ConnectionString = connection
    con.Open()
    Dim adapter As New OleDbDataAdapter(Sql, connection)
    Dim results As New DataTable("result")
    adapter.Fill(results)
    con.Close()
    dgwTechStatus.DataSource = results

您需要将datagridview的“ autogeneratecolumns”属性设置为true,或将特定的绑定列添加到datagridview。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM