Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Table's definition...

Table's definition...

Scheduled Pinned Locked Moved C#
csharpdatabasesql-serversysadminhelp
6 Posts 4 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Adeel Chaudhry
    wrote on last edited by
    #1

    Hello! Is there any way to get the table's definition (SQL Server 2005) in C#? Regards, Adeel

    Do rate the reply, if it helps or even if it doesnot, because it helps the members to know, what solved the issue. Thanks.

    D S P 3 Replies Last reply
    0
    • A Adeel Chaudhry

      Hello! Is there any way to get the table's definition (SQL Server 2005) in C#? Regards, Adeel

      Do rate the reply, if it helps or even if it doesnot, because it helps the members to know, what solved the issue. Thanks.

      D Offline
      D Offline
      dan sh
      wrote on last edited by
      #2

      You can execute stored procedure "sp_tables" through code to get list of tables and "sp_columns @tablename" to get the name type etc of each column of a table.

      Avoid Google. Use Blackle[^]

      A 1 Reply Last reply
      0
      • D dan sh

        You can execute stored procedure "sp_tables" through code to get list of tables and "sp_columns @tablename" to get the name type etc of each column of a table.

        Avoid Google. Use Blackle[^]

        A Offline
        A Offline
        Adeel Chaudhry
        wrote on last edited by
        #3

        Thanks for your reply, but i doubt if they are C# classes/libraries...! :)

        Do rate the reply, if it helps or even if it doesnot, because it helps the members to know, what solved the issue. Thanks.

        D 1 Reply Last reply
        0
        • A Adeel Chaudhry

          Thanks for your reply, but i doubt if they are C# classes/libraries...! :)

          Do rate the reply, if it helps or even if it doesnot, because it helps the members to know, what solved the issue. Thanks.

          D Offline
          D Offline
          dan sh
          wrote on last edited by
          #4

          These are stored procedures provided by SQL Server to get database and table schemas. You can run these using SQLCommand and read the out come using SQLDataReader class.

          Avoid Google. Use Blackle[^]

          1 Reply Last reply
          0
          • A Adeel Chaudhry

            Hello! Is there any way to get the table's definition (SQL Server 2005) in C#? Regards, Adeel

            Do rate the reply, if it helps or even if it doesnot, because it helps the members to know, what solved the issue. Thanks.

            S Offline
            S Offline
            sunspeed
            wrote on last edited by
            #5

            The Connection object provides you the "GetSchema()" method, which returns a DataTable filled with schema informations. You have to specifiy what information you want in parameters of the method. Example: DataTable _indicesSchema = null; using (OleDbConnection connection = new OleDbConnection("Provider=SQLOLEDB;Password=******;Persist Security Info=True;User ID=sa;Initial Catalog=*****;Data Source=*******")) connection.Open(); _indicesSchema = connection.GetSchema("Indexes", new string[] { null, null, null, null }); connection.Close(); } Hope was helpfull

            Tiefe Brunnen muss man graben wenn man klares Wasser will, tiefe Wasser sind nicht still.

            1 Reply Last reply
            0
            • A Adeel Chaudhry

              Hello! Is there any way to get the table's definition (SQL Server 2005) in C#? Regards, Adeel

              Do rate the reply, if it helps or even if it doesnot, because it helps the members to know, what solved the issue. Thanks.

              P Offline
              P Offline
              Pete OHanlon
              wrote on last edited by
              #6

              Take a look at the GetSchema command on your connection object. It has all sorts of useful abilities for retrieving information about the database. I mention this one rather than directing you towards particular tables/stored procedures in the database because it gives you the option to discover information from lots of different database types.

              Deja View - the feeling that you've seen this post before.

              My blog | My articles

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups