本文介绍了问题显示SQL结果中的DataGridView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的应用程序中的数据网格视图中显示一个SQL查询的结果。下面code是什么,我已经写了,但它dosent似乎无论我做什么,我不能让我的形式在DataGridView任何显示。任何人都可以点我朝着正确的方向?

code:

  [SQL =SELECT * FROM招贤纳才WHERE techID =&放大器; TechScreenID和放大器;

    连接=供应商= Microsoft.Jet.OLEDB.4.0;数据源= C:\用户\戴夫\文件\ joblist.mdb;
    con.ConnectionString =连接
    con.Open()
    昏暗的适配器作为新OleDbDataAdapter的(SQL,连接)
    昏暗的结果作为新的DataTable(结果)
    adapter.Fill(结果)
    con.Close()
    dgwTechStatus.DataSource =结果
 

解决方案

您需要在DataGridView的的AutoGenerateColumns属性设置为true,或添加特定的绑定列到你的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
解决方案

You need to set the datagridview's "autogeneratecolumns" property to true, or add specific bound columns to your datagridview.

这篇关于问题显示SQL结果中的DataGridView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 22:11