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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. How to create a table on Click event

How to create a table on Click event

Scheduled Pinned Locked Moved Database
csharpdatabasetutorialquestion
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.
  • S Offline
    S Offline
    sacr83
    wrote on last edited by
    #1

    Hi All, I have some prob in c#.So i want to CREATE a TABLE on Button's "click" event.That's mean when I click on "ok" botton "a new table have to create on my existing DATABASE ".So how i do it in C#..? ReGardZ "ChiNthaKa"

    CheeN

    A B R 3 Replies Last reply
    0
    • S sacr83

      Hi All, I have some prob in c#.So i want to CREATE a TABLE on Button's "click" event.That's mean when I click on "ok" botton "a new table have to create on my existing DATABASE ".So how i do it in C#..? ReGardZ "ChiNthaKa"

      CheeN

      A Offline
      A Offline
      Ashfield
      wrote on last edited by
      #2

      The same as you do any other time, issue a CREATE TABLE command - for example CREATE TABLE Fred(Column1 int NOT NULL, Column2 varchar(50) NULL...etc)

      Bob Ashfield Consultants Ltd

      1 Reply Last reply
      0
      • S sacr83

        Hi All, I have some prob in c#.So i want to CREATE a TABLE on Button's "click" event.That's mean when I click on "ok" botton "a new table have to create on my existing DATABASE ".So how i do it in C#..? ReGardZ "ChiNthaKa"

        CheeN

        B Offline
        B Offline
        Blue_Boy
        wrote on last edited by
        #3

        Create SQL Table using C# code.[^]


        I Love T-SQL

        A 1 Reply Last reply
        0
        • B Blue_Boy

          Create SQL Table using C# code.[^]


          I Love T-SQL

          A Offline
          A Offline
          Ashfield
          wrote on last edited by
          #4

          yep, thats another way :)

          Bob Ashfield Consultants Ltd

          B 1 Reply Last reply
          0
          • A Ashfield

            yep, thats another way :)

            Bob Ashfield Consultants Ltd

            B Offline
            B Offline
            Blue_Boy
            wrote on last edited by
            #5

            yep :)


            I Love T-SQL

            1 Reply Last reply
            0
            • S sacr83

              Hi All, I have some prob in c#.So i want to CREATE a TABLE on Button's "click" event.That's mean when I click on "ok" botton "a new table have to create on my existing DATABASE ".So how i do it in C#..? ReGardZ "ChiNthaKa"

              CheeN

              R Offline
              R Offline
              Rohan Priya
              wrote on last edited by
              #6

              Hi Chinthaka , You can write the following code in the button onclick event . Before that you should import System.Data.SqlClient namespace . SqlConnection conn= new SqlConnection("ConnectionString"); conn.Open(); MessageBox.Show("Connection est.."); SqlCommand comCreate = new SqlCommand("CREATE TABLE EMP_TABLE_CREATE(EmpID INT , EmpName VARCHAR(20))",conn); int intCreate = comCreate.ExecuteNonQuery(); MessageBox.Show("Table Created.." + intCreate); SqlCommand conInsert = new SqlCommand("INSERT INTO EMP_TABLE_CREATE VALUES(11,'MyName')",conn ) ; int intInsert = conInsert.ExecuteNonQuery(); MessageBox.Show("Row Inserted.." + intInsert); MessageBox.Show("Displaying Row : "); SqlCommand conSelect = new SqlCommand("SELECT * FROM EMP_TABLE_CREATE",conn) ; SqlDataReader dr= conSelect.ExecuteReader(); dr.Read(); while(dr.HasRows) { MessageBox.Show(dr.GetInt32(0).ToString() +":"+dr.GetString(1)) ; dr.NextResult(); } conn.Close(); Hope this is what you wanted . Let me know if you have any further queries . Thanks

              Priya Rohan

              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