Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to take all the names of tables in a database (sql server), and create a tab page for each..

C#
public void FillTabControl(TabControl tabControl)
        {

            sqlQuery = @"SELECT * FROM SYSOBJECTS WHERE XTYPE='U'";

            con = fdc.NewConnection();
            command = new SqlCommand(sqlQuery, con);

            try
            {
                con.Open();

                sqlReader = command.ExecuteReader();

                while (sqlReader.Read())
                {
                    tabPage = new TabPage(sqlReader.GetName(0));
                    tabControl.TabPages.Add(tabPage);
                }

            }
            catch
            {

            }
            finally
            {
                con.Close();
            }
        }


I need a string with the TABLE NAME, it doesn't work... How i read the output of this command ?
Posted
Updated 27-Nov-13 1:46am
v2
Comments
lukeer 27-Nov-13 7:33am    
Ok. Go ahead.

That should read: "What is your question? Use the 'Improve question' link and re-word your text to actually contain a question along with information that people enables to help you."

And you did use the "pre" tags correctly. That does't go without saying for every poster.
[no name] 27-Nov-13 8:15am    
what is this "XTYPE='U'"?

1 solution

Did you Google for, yet?[^]

[update]
Quote:
Ok, i already know the query to select all tables, but i doesn't know how to read the output of this query in C# to know the names of each table...
Then Google better![^]
[/update]
 
Share this answer
 
v2
Comments
Rieth L 27-Nov-13 7:54am    
Ok, i already know the query to select all tables, but i doesn't know how to read the output of this query in C# to know the names of each table...
Rieth L 27-Nov-13 8:10am    
Ok, ok, im "sleeping", sorry, i found, thanks
CPallini 27-Nov-13 8:18am    
You are welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900