Results 1 to 5 of 5

Thread: creating column by code

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2002
    Location
    near by moon
    Posts
    4

    Lightbulb creating column by code

    hi
    I want to add a culomn to SQL server by writing code in vb.
    how can I Do that?

    best regards,
    Sam

  2. #2
    Fanatic Member Gaffer's Avatar
    Join Date
    Nov 2000
    Location
    London
    Posts
    828
    First you need to connect to the database - use ADO.
    Then:

    cn.Execute "ALTER myTable ADD myField varchar(100)"

  3. #3
    PowerPoster abhijit's Avatar
    Join Date
    Jun 1999
    Location
    Chit Chat Forum.
    Posts
    3,228
    Since you are using SQL Server, there are two more options available apart from the one that Gaffer mentioned.

    The options are using ADOX and SQL-DMO. Read up on both and choose the one that suits you better. In my opinion SQL-DMO score way above ADOX.

    Cheers!
    Abhijit
    Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
    save a blobFileStreamDataTable To Text Filemy blog

  4. #4
    Fanatic Member Gaffer's Avatar
    Join Date
    Nov 2000
    Location
    London
    Posts
    828
    true. However if speed is your thing, I believe ALTER TABLE will be quicker

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2002
    Location
    near by moon
    Posts
    4
    thanks to both of you.
    I use the SQL is it right with SQL too?
    I mean that sentence which gaff mentioned.

    regards,
    Sam

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width