Alter Table Trouble

Results 1 to 2 of 2

Thread: Alter Table Trouble

  1. #1
    Join Date
    Dec 1969

    Default Alter Table Trouble

    I am having great trouble adding a field to a table using the ALTER TABLE command. The trouble occurs when I try to use a variable as my field name as the following code shows:<BR><BR>Set objCmd = Server.CreateObject("ADODB.Command")<BR>Set objCmd.ActiveConnection = objConn<BR>objCmd.CommandText = "ALTER TABLE tPlayers ADD " & gDate & " TEXT NULL"<BR>objCmd.CommandType = adCmdText<BR>objCmd.CommandTimeout = 30<BR>objCmd.Prepared = False<BR>objCmd.Execute<BR><BR>I get the following error:<BR><BR>Syntax error in field definition<BR><BR>I can add a field without using a variable, but to be more dynamic I need to use a variable.<BR><BR>Can anyone help?<BR><BR>Cheers<BR><BR>Anthony<BR>anthony@iams

  2. #2
    Join Date
    Dec 1969

    Default Well debug this

    ; )<BR><BR>Add the code above your code:<BR><BR>strSQL = "ALTER TABLE tPlayers ADD " & gDate & " TEXT NULL" <BR>response.write strSQL<BR>response.end<BR><BR>What do you get? <BR>

Posting Permissions

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