Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
What are the tables names in my database :)
Message
De
13/08/2002 06:54:55
Fausto Garcia
Independent Developer
Lima, Pérou
 
 
À
13/08/2002 05:04:14
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Divers
Thread ID:
00689017
Message ID:
00689034
Vues:
24
Hi Erik,

Database management systems implement propietary methods to store diverse database information. If you are using VFP for example you can find every database object on the .DBC file. Under MS SQL Server you can find this info as records of the "sysobjects" table. The following code corresponds to an .aspx page which shows you the name of all user tables existing on the Northwind database -that ships with SQL Server and Access- on a DropDownList control and displays the entire content of the table you select.
<% @Page Language="vb" %>
<% @Import Namespace="System.Data" %>
<% @Import Namespace="System.Data.SqlClient" %>

<body>
   <script runat="server">

   Private cnn As New SqlConnection("uid=sa;server=(local);database=northwind")
   Private dap As New SqlDataAdapter("SELECT id,name FROM sysobjects WHERE xtype='U' ORDER BY name", cnn)
   Private dst As New DataSet()

   Sub Page_Load(s As Object, e As EventArgs)
      If Not Page.IsPostBack Then
         'First time we are accessing the page, we load values on the DropDownList control
         dap.Fill(dst, "Catalog")
         With ddlCatalog
            .DataSource = dst.Tables("Catalog")
            .DataTextField = "name"
            .DataValueField = "id"
            .DataBind()
         End With
      Else
         'Subsequent postbacks of page
         lblTable.Text = ddlCatalog.SelectedItem.Text
         dap.SelectCommand.CommandText = "SELECT * FROM " & ddlCatalog.SelectedItem.Text
         dap.Fill(dst, "GenTable")
         With dgdTable
            .DataSource = dst.Tables("GenTable")
            .DataBind()
         End With
      End If
   End Sub
   </script>
   <form runat="server">
      <asp:dropdownlist id="ddlCatalog" runat="server" Width="209px" AutoPostBack="True"></asp:DropDownList>
      <asp:label id="lblTable" font-size="medium" font-bold forecolor="brown" runat="server">
         * Name of selected table *
      </asp:label>
      <p />
      <asp:datagrid id="dgdTable" width="500" runat="server" />
   </form>
</body>
I do not know where does Access store this information, on a system table maybe. Shall you find out and make the necessary changes to put this code work for you.

Hope this helps you! Greetings,
Solo se que nada se

Fausto J. Garcia Pino - MCSD.NET
.NET, Oracle, Tronador & Fondismo!
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform