|
-
Apr 12th, 2004, 07:12 AM
#1
Thread Starter
New Member
I'll Try here!!
I posted this on the Database Section with no luck, maybe I will have better luck here.
I am very novice to programming, so please bare with me.
I am working on a couple of projects to help me learn and have an idea for one that I would like to try.
Scope: Create a ListBox that will list all the tables columns for a given table.
Problem: The database I want to use has a LOT!!! of tables in it and when I set my adapter I have to add all those table and columns to it. I am sure there is a better way but not sure, and this is where I am asking for your help.
What I have and know so far.
Have a TextBox Where the user enters the table they want to see the fields.
Have a ListBox to Display Data
Have a Button that will Trigger the Event
PsedoCode
//On_Click Event
DataSet21.Clear()
OracleDataAdapter1.Fill(DataSet21, "TABLENAME")
Dim myTable As DataTable = DataSet21.TABLENAME
Dim col As DataColumn
For Each col In myTable.Columns
ListBox1.Items.Add(col.ColumnName)
Next
End Sub
I Have tested the above code and all is well, but I am not sure what is a good way to to get all the tables into the dataset and adapter without adding all of them.
If you any of you have any suggestions, great!! I would really appriciate it.
Thanks in advance
-
Apr 12th, 2004, 06:07 PM
#2
Thread Starter
New Member
Something wrong???
Is the question I am asking to vauge? Or does it not make sense at all? I wish I could explain it better but being new to programming in general I do not know how to word it better. If someone knows what I am trying to get at but knows how to word it better please do so.
Thanks everyone
-
Apr 12th, 2004, 09:33 PM
#3
PowerPoster
What I would do is select only one record from the table if the only thing you are doing with the data is getting the column names.
To do that, run a statement like so:
Dim strQuery As String = "SELECT TOP 1 * FROM " & TableName
Or, you can reference the sqldmo com object and use that to be more efficient, but then it wouldn't be a .net only solution.
-
Apr 13th, 2004, 09:12 AM
#4
Thread Starter
New Member
Thank you for the reply, but the problem I am having is knowing which table to read the columns from.
In a TextBox field I want to enter the table name
Button_Onclick_Event read the TextBox and connect to the DB and select from that table, then read and list the columns in the Listbox.
Thanks again for replying
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
|