update and insert query error, but select works ok.

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default update and insert query error, but select works ok.

    :rose;
    Any ideas spring to mind about the following issue?

    I'm getting an error trying to run an Update or Insert query. I can run a
    Select query in the application, but not Insert or Update.
    The Update and Insert queries works with SQL Query Analyzer.

    Thanks.




    <cfquery name="qUpSite" datasource="#request.optomDS#">
    insert into optomSite
    (SiteName)
    VALUES('ThirdSite')
    </cfquery>

    <cfquery name="qUpSite" datasource="#request.optomDS#">
    update optomSite
    SET SiteName='TestSite'
    where siteID = 1
    </cfquery>

    <cfquery name="qUpSite" datasource="#request.optomDS#">
    SELECT *
    FROM optomSite
    where siteID = 1
    </cfquery>

    JoyRose Guest

  2. Similar Questions and Discussions

    1. HELP SQL Update syntax error in windows2003 but works fine in NT4???
      We upgraded our production server to windows 2003 and have been seeing this error when trying to update the database through a cfquery tag: ODBC...
    2. CF_SQL_BIT works on Insert, not on Update
      Aaarrgghhh! For some reason, insert and update Stored Procedures are behaving differently, and there is not discernable reason for it. Here are...
    3. IIF in Select Query Error
      Hello, I need to create a query with a date calculation of elapsed minutes. And, I have made this work. Now I find that some of the...
    4. trying to update a table after making a join select query on two tables
      here is my problem distilled down I need to be able to change the title of a book associated with an author there are 2 tables "author" and "books"...
    5. Use a SELECT @@IDENTITY as a sub-query in an UPDATE ?
      It didn't work. UPDATE tblBlogs SET link_ID = blog_ID WHERE blog_ID = @@IDENTITY I get this error when trying to save an Access query: ...
  3. #2

    Default Re: update and insert query error, but select works ok.

    Your queries look fine. What's the error you're getting?

    Also, just to cut back on the ping-pong questions and incase it's relevant
    once you post the error:

    what database?
    what datatypes are those columns?

    Kronin555 Guest

  4. #3

    Default Re: update and insert query error, but select works ok.

    Thanks for replying.

    Part of the problem is I'm not getting a useful error:
    12:06:01.001 - Database Exception - in
    F:\DEV\Internet\Misc\JHolman\Optometry_db\optomAdm in\act_data2db.cfm : line 14
    Error Executing Database Query.

    SQL Server

    siteID type = int (automatic identity column, primary key)
    siteName type= varchar, length 100 ( no nulls allowed)

    Like I said, the queries run fine in SQL Query Analyzer. The table is updated,
    no problem.

    Thanks for whatever insights you can offier!


    JoyRose Guest

  5. #4

    Default Re: update and insert query error, but select works ok.

    In the CF administrator, check Enable Robust Exception Information and any other database options so that the error message will provide more information.
    mxstu Guest

  6. #5

    Default Re: update and insert query error, but select works ok.

    Are you allowing Update and Insert statements to be executed for that
    datasource? I've never disabled those, so I don't know if Coldfusion would give
    you a nicer error message or not...

    Also, do what mxstu said. Enable Robust Exception Information and also check
    Exception Information further down on that page.

    Kronin555 Guest

  7. #6

    Default Re: update and insert query error, but select works ok.

    I'm checking with the web server admin on that.

    Another thing, but I don't think it could be related:
    I've got security set up in the app. I use a cfif statement checking for
    IsUserInRole(2) in the index page.
    Everything else in the app works and the insert and update queries are called
    into the index page. I also
    tried the insert and update queries right after the security check and they
    still don't work.

    JoyRose Guest

  8. #7

    Default Re: update and insert query error, but select works ok.

    Yes. Check the datasource options that Kronin555 mentioned. Make sure
    INSERT and UPDATE are checked in the "Allow SQL" section. If those options
    are unchecked (ie. disallowed), CF will usually give you a message like:

    "Error Executing Database Query.
    Executing the SQL statement is not allowed. "

    mxstu Guest

  9. #8

    Default Re: update and insert query error, but select works ok.

    I just noticed your question about allowing Update and Insert to be executed
    for that datasource. That would be set by the SQL DBA, right? Would the SQL
    Query Analyzer update the table if Update and Insert weren't allowed for the
    datasource? Or are datasource permissions set in Cold Fusion Admin?

    JoyRose Guest

  10. #9

    Default Re: update and insert query error, but select works ok.

    No. You can set allowed sql operations in the CF Administrator. It is high
    level and essentially allows you to say "do not allow ANY insert operations
    for this datasource...." or ... "allow insert, delete and update operations
    only".

    Another possibility is that the account used to define the datasource has the
    wrong the wrong database permissions. Did you test your queries in the query
    analyzer using the same account used for the CF datasource?

    There are a few possibilities but I would look at the detailed error message
    first. It will tell you what the problem is.

    mxstu Guest

  11. #10

    Default Re: update and insert query error, but select works ok.

    I didn't have permission through ColdFusion Admin.
    All better. :+>

    Thanks for your help everyone!!

    Make sure INSERT and UPDATE are checked in the "Allow SQL" section. If those
    options are unchecked (ie. disallowed), CF will usually give you a message like:

    JoyRose Guest

Posting Permissions

  • You may not post new threads
  • You may 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