|
-
May 20th, 2013, 07:24 AM
#1
Thread Starter
New Member
Choose datatables with combobox and display data in datagridview
Any idea, how to choose data tables with combo box and display data in data grid view?
I have 80 tables in database, and i need to have combo box which will be populated with data table names,
when i select certain data table i expect to that specific table populate data grid view.
any solutions?
-
May 20th, 2013, 07:49 AM
#2
Re: Choose datatables with combobox and display data in datagridview
Follow the CodeBank link in my signature and check out my thread on Getting Schema Information. It shows how to get various schema information using the appropriate DbConnection object. Once you have a DataTable containing the schema information for your tables, you can bind it to a ComboBox in the normal way. When the user makes a selection, get the table name from the Text property and insert that into a SQL Select statement and use that to query the database as you normally would. I've also got a thread in the CodeBank about Retrieving & Saving Data if you need help on that part.
-
May 20th, 2013, 08:02 AM
#3
Re: Choose datatables with combobox and display data in datagridview
Sorry, I think that thread about getting schema info is one that I intended to write but never got around to. This is for SQL Server but will be very similar for other databases:
Code:
Using connection As New SqlConnection("connection string here")
connection.Open()
Dim table = connection.GetSchema("Tables")
With ComboBox1
.DisplayMember = "TABLE_NAME"
.DataSource = table
End With
End Using
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|