|
-
Aug 19th, 2008, 02:50 PM
#1
Thread Starter
Member
[2005] Choosing Tables
Hi,
How u make that all your table come in a combobox and you can select your table and then the data from that table loads into the datagrid and u can change it...
-
Aug 19th, 2008, 03:08 PM
#2
Re: [2005] Choosing Tables
That would depend on the backend database. They all store the metadata in different areas for you to find.
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Aug 19th, 2008, 03:53 PM
#3
Re: [2005] Choosing Tables
As Gary mentioned, what database are you using?
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Aug 19th, 2008, 04:15 PM
#4
Thread Starter
Member
Re: [2005] Choosing Tables
-
Aug 19th, 2008, 11:50 PM
#5
Re: [2005] Choosing Tables
vb.net Code:
Dim table As DataTable Using connection As New OleDbConnection("connection string here") connection.Open() table = connection.GetSchema("TABLES") End Using myComboBox.DisplayMember = "TABLE_NAME" myComboBox.DataSource = table
Thos enames work in SQL Server and I think they're the same in Access. If not you can just do little testing to get the right collection and column names.
-
Aug 20th, 2008, 05:39 AM
#6
Thread Starter
Member
Re: [2005] Choosing Tables
well this doesnt set the databases automatic in the combo list if i see good
-
Aug 20th, 2008, 06:29 AM
#7
Frenzied Member
Re: [2005] Choosing Tables
This code will load the combo box with the names of the data tables and not the schema tables such as MSysAccessObjects, MSysACEs, MSysObjects, MSysQueries and MSysRelationships if that is what you are looking for from an Access data base.
vb Code:
Private Sub btnLoadComboBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoadComboBox1.Click
' Returns schema information for the data source (Data Base)
Dim restrictions() As String = {Nothing, Nothing, Nothing, "TABLE"}
Dim table As DataTable
Using connection As New OleDbConnection("connection string")
connection.Open()
table = connection.GetSchema("TABLES", restrictions)
End Using
For Each dr As DataRow In table.Rows
Me.cboLoadComboBox1.Items.Add(dr("TABLE_NAME"))
Me.cboLoadComboBox1.SelectedIndex = 0
Me.cboLoadComboBox1.Sorted = True
Next
End Sub
Last edited by CoachBarker; Aug 28th, 2008 at 02:00 PM.
-
Aug 28th, 2008, 11:51 AM
#8
Re: [2005] Choosing Tables
Please do not post duplicate threads.
Dup Thread Deleted
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 28th, 2008, 02:06 PM
#9
Frenzied Member
Re: [2005] Choosing Tables
What does not work??? You have to be more specific.
Add a new form to a project
Add a combo box to the form and call it cboLoadComboBox1
Add a button to the form and call it btnLoadComboBox1
In design view double click on the button and copy and past this part of the code into the button click event
vb Code:
' Returns schema information for the data source (Data Base)
Dim restrictions() As String = {Nothing, Nothing, Nothing, "TABLE"}
Dim table As DataTable
Using connection As New OleDbConnection("connection string")
connection.Open()
table = connection.GetSchema("TABLES", restrictions)
End Using
For Each dr As DataRow In table.Rows
Me.cboLoadComboBox1.Items.Add(dr("TABLE_NAME"))
Me.cboLoadComboBox1.SelectedIndex = 0
Me.cboLoadComboBox1.Sorted = True
Next
don't forget to add your connection string and it will load the name of the tables in the database.
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
|