Professional Web Applications Themes

ASP Command Object Syntax Errors - Dreamweaver AppDev

I'm having difficulty using a straight-forward ASP/VBScript Command Object generated by DMX04. The code is supposed to insert into a SQL Server 2000 table, not a stored procedure. Dreamweaver writes the code as follows: <% set cmdAttachAdd = Server.CreateObject("ADODB.Command") cmdAttachAdd.ActiveConnection = connectionStringGoesHere cmdAttachAdd.CommandText = "INSERT INTO dbo.tableName (entryID, fileName) VALUES (" + Replace(cmdAttachAdd__varEntryID, "'", "''") + "," + Replace(cmdAttachAdd__varFileName, "'", "''") + ") " cmdAttachAdd.CommandType = 1 cmdAttachAdd.CommandTimeout = 0 cmdAttachAdd.Prepared = true cmdAttachAdd.Execute() %> ...plus the usual variable declarations, etc. The syntax error indicates that the problem is in the CommandText, or SQL string. I've tried removing the "Replace" ...

  1. #1

    Default ASP Command Object Syntax Errors

    I'm having difficulty using a straight-forward ASP/VBScript Command Object
    generated by DMX04. The code is supposed to insert into a SQL Server 2000
    table, not a stored procedure. Dreamweaver writes the code as follows:

    <%

    set cmdAttachAdd = Server.CreateObject("ADODB.Command")
    cmdAttachAdd.ActiveConnection = connectionStringGoesHere
    cmdAttachAdd.CommandText = "INSERT INTO dbo.tableName (entryID, fileName)
    VALUES (" + Replace(cmdAttachAdd__varEntryID, "'", "''") + "," +
    Replace(cmdAttachAdd__varFileName, "'", "''") + ") "
    cmdAttachAdd.CommandType = 1
    cmdAttachAdd.CommandTimeout = 0
    cmdAttachAdd.Prepared = true
    cmdAttachAdd.Execute()

    %>

    ...plus the usual variable declarations, etc. The syntax error indicates that
    the problem is in the CommandText, or SQL string. I've tried removing the
    "Replace" function and using Chr(34) or other character substitutions instead
    of the single quotes, but no luck.

    Can anyone shed any light as to how to correct this?

    Thanks.

    fiddlestyx Guest

  2. #2

    Default Re: ASP Command Object Syntax Errors

    What's your error?
    In all liklihood, your parameter values don't exist. You have no single
    quotes around the values, so they're numbers. If a number parameter doesn't
    exist, then the statement will error out. If you pass a text string into a
    number parameter, the statement will error out.

    "fiddlestyx" <webforumsusermacromedia.com> wrote in message
    news:cv5evv$1o$1forums.macromedia.com...
    > I'm having difficulty using a straight-forward ASP/VBScript Command Object
    > generated by DMX04. The code is supposed to insert into a SQL Server 2000
    > table, not a stored procedure. Dreamweaver writes the code as follows:
    >
    > <%
    >
    > set cmdAttachAdd = Server.CreateObject("ADODB.Command")
    > cmdAttachAdd.ActiveConnection = connectionStringGoesHere
    > cmdAttachAdd.CommandText = "INSERT INTO dbo.tableName (entryID, fileName)
    > VALUES (" + Replace(cmdAttachAdd__varEntryID, "'", "''") + "," +
    > Replace(cmdAttachAdd__varFileName, "'", "''") + ") "
    > cmdAttachAdd.CommandType = 1
    > cmdAttachAdd.CommandTimeout = 0
    > cmdAttachAdd.Prepared = true
    > cmdAttachAdd.Execute()
    >
    > %>
    >
    > ...plus the usual variable declarations, etc. The syntax error indicates
    that
    > the problem is in the CommandText, or SQL string. I've tried removing the
    > "Replace" function and using Chr(34) or other character substitutions
    instead
    > of the single quotes, but no luck.
    >
    > Can anyone shed any light as to how to correct this?
    >
    > Thanks.
    >

    CMBergin Guest

Similar Threads

  1. AS2: Extends with packages (works) but gives check syntax errors (seems to be a bug)
    By Yechezkal Gutfreund in forum Macromedia Flash Actionscript
    Replies: 1
    Last Post: February 27th, 05:46 PM
  2. Check syntax gives strange errors
    By KGA webforumsuser@macromedia.com in forum Macromedia Flash Actionscript
    Replies: 0
    Last Post: January 30th, 12:25 AM
  3. Command line Syntax
    By Manish Uskaikar in forum PERL Beginners
    Replies: 3
    Last Post: December 1st, 04:59 PM
  4. Grant Command Syntax
    By Kubaton Lover in forum PHP Development
    Replies: 0
    Last Post: November 4th, 07:58 PM
  5. finding syntax errors
    By Kevin Pfeiffer in forum PERL Beginners
    Replies: 2
    Last Post: October 27th, 08:15 AM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139