Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
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
 
Posted 23-Sep-12 15:02pm
rony001265
Comments
Sergey Alexandrovich Kryukov at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 498
1 OriginalGriff 439
2 ChintanShukla 305
3 Richard Deeming 250
4 RyanDev 210
0 Sergey Alexandrovich Kryukov 8,901
1 OriginalGriff 7,571
2 CPallini 2,603
3 Richard MacCutchan 2,095
4 Abhinav S 1,893


Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 24 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100