Click here to Skip to main content
15,867,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.

VB
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES 


VB
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
Posted
Comments
Sergey Alexandrovich Kryukov 23-Sep-12 23:45pm    
I think it can be pretty hard to populate 3.5 tables. Why not using integer number of tables, 3 or 4? :-)
--SA

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900