vb10中的组合框错误

时间:2014-01-23 16:51:50

标签: sql-server visual-studio-2010 combobox

嘿,我正在尝试在组合框中连接我的数据库。程序正在读取它,但结果是System.Data.DataRowView。你能帮助我吗?这是我的代码

表单加载

Dim query as String
query  = "SELECT proj_name FROM Project"
Dim dt as New Datatable
dt = ExecuteQuery(query) 'ExecuteQuery is where my database is connected. the one that queries

cmbProj.DataSource = dt

我的ExecuteQuery()代码

Dim connectionString As String = "Data Source=jordan;Initial Catalog=PayrollThesis;Integrated Security=True"
Public Function ExecuteQuery(ByVal query As String) As DataTable
    Try
        Dim Con As New SqlConnection(connectionString)
        Dim DA As New SqlDataAdapter(query, Con)
        Dim CB As New SqlCommandBuilder(DA)
        Dim DT As New DataTable
        DA.Fill(DT)
        Return DT
    Catch ex As Exception
        MessageBox.Show(ex.Message)
        Return Nothing
    End Try
End Function
希望这已经足够了。 :)

0 个答案:

没有答案