Jump to content

populating a combo box with sql server 3.5 tables


rony_78
 Share

Recommended Posts

i am 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 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 DataTablePrivate 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

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...