Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    Lincoln (UK)
    Posts
    138
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Adding checkbox colums to DB table (ALTER TABLE)

    Hi all,
    I'm trying to add a checkbox column to a table in my db.
    I have been able to add a text column but can't seem to find the right instruction to add a check box.

    Any ideas?

    This is the code I'm using to add a text column:
    Code:
    set Command1 = Server.CreateObject("ADODB.Command")
    Command1.ActiveConnection = vMyConnection
    Command1.CommandText = "ALTER TABLE ShopTblCountries ADD ColumnName VARCHAR(10);"
    Command1.Execute()
    Further thought:
    The value, if possible, needs to be pre-set to 'True'
    Last edited by Keltoi; 12-12-2003 at 04:47 PM.

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    You are not going to be bale to add a text box, but you can add a bollean column that will hold True or false and then when you write your code to the page you would have to right out checkboxes.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Lincoln (UK)
    Posts
    138
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thanks, (and sorry for the delay in replying)

    It's a great shame that it doesn't seem to be possible to add a check box column.

    Does anyone know the SQL to add a value to all fields in the new column being created?

  • #4
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post
    If I understand you right, you would just

    "UPDATE tableName SET fieldName = 'yourvalue'"
    Omnis mico antequam dominus Spookster!

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Location
    Lincoln (UK)
    Posts
    138
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thanks, Thought of that, was just wondering if it could be done whilst creating the column.

    For those who would like to know, I've actually discovered a way to create a checkbox column.
    Just working on a way to set it's default value:
    Code:
    ALTER TABLE ShopTblCountries ADD FirstCheckBox BIT
    Any ideas anyone?
    Have tried
    Code:
    ALTER TABLE ShopTblCountries ADD FirstCheckBox BIT DEFAULT 1
    but no good (syntax error)

    Think I may just run an update


  •  

    Posting Permissions

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