用SQL Server 3.5表填充组合框 [英] populating a combo box with sql server 3.5 tables
本文介绍了用SQL Server 3.5表填充组合框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是vb.net的新手,难以使用SQL Server Compact 3.5 tables填充组合框.我遇到以下错误未处理NotSuppoertedException"
在此行中的错误-Me.ComboBox1.DataSource = Me.con.GetSchema("TABLES")
可以给我一些有关如何使用sql查询而不是GetSchema方法的帮助吗.
I am new to vb.net, having difficulty populating combobox with sql server compact 3.5 tables.i am encountering the following error "NotSuppoertedException was unhandled "
in this line Error - Me.ComboBox1.DataSource = Me.con.GetSchema("TABLES")
can someome please help me on how do i use the sql query instead of GetSchema method.
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
Private con As New SqlCeConnection("Provider=;Data Source= C:\Program Files\Microsoft SQL Server Compact Edition\v3.5\Samples\Northwind.sdf;Persist Security Info=False")
Private adapter As New SqlCeDataAdapter(String.Empty, Me.con)
Private data As DataTable
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As EventArgs) Handles MyBase.Load
con.Open()
Me.ComboBox1.DisplayMember = "TABLE_NAME"
Me.ComboBox1.ValueMember = "TABLE_NAME"
Me.ComboBox1.DataSource = Me.con.GetSchema("TABLES")
con.Close()
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, _
ByVal e As EventArgs) Handles ComboBox1.SelectedIndexChanged
If Me.ComboBox1.SelectedItem IsNot Nothing Then
Me.data = New DataTable
Me.adapter.SelectCommand.CommandText = String.Format("SELECT * FROM [{0}]", Me.ComboBox1.SelectedValue)
Me.adapter.Fill(Data)
Me.DataGridView1.DataSource = Nothing
Me.DataGridView1.Columns.Clear()
Me.DataGridView1.DataSource = Me.data
End If
End Sub
.Back to top
推荐答案
从此处开始:
> http://stackoverflow.com/questions/4017528/how- to-get-all-tables-names-in-sqlce-database [ SQL Server CE查询工具 [
Start here :
http://stackoverflow.com/questions/4017528/how-to-get-all-tables-names-in-sqlce-database[^]
See it in action:
SQL Server CE Query Tool[^]
这篇关于用SQL Server 3.5表填充组合框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文