Batch statements.

Author Message
dodad

  • Total Posts : 3
  • Scores: 0
  • Reward points : 0
  • Joined: 6/26/2008
  • Status: offline
Batch statements. Thursday, June 26, 2008 6:00 AM (permalink)
0
Using vbscript and sql server 2000.  Kind of new at this.
 
Been trying all morning to execute a group of insert statement in one call.  Everything works fine but if there is an error in one of the statements I don't get an error in my vbscript page.  I tried setting xact_abort to true which aborts and rollsback the batch but I still need to get an error.
 
 
NL is a new line.
 [size=2]
 sql = "SET XACT_ABORT ON" & NL
 sql = sql & "INSERT INTO ChunkTable1 (StringData) VALUES ('This');" & NL
 sql = sql & "INSERT INTO ChunkTable1 (StringData) VALUES ('is');" & NL
 sql = sql & "INSERT INTO ChunkTable1 (StringData) VALUES ('only');" & NL
 sql = sql & "INSERT INTO ChunkTable1 (StringData) VALUES ('a');" & NL
 sql = sql & "INSERT INTO ChunkTable1 (StringData) VALUES ('test');" & NL
 sql = sql & "INSERT INTO ChunkTable1 (StringData) VALUES ('String which is too big and will cause an error');" & NL
 sql = sql & "INSERT INTO ChunkTable1 (StringData) VALUES ('One');" & NL
 sql = sql & "INSERT INTO ChunkTable1 (StringData) VALUES ('more');" & NL
 sql = sql & "INSERT INTO ChunkTable1 (StringData) VALUES ('test');" & NL
  
 
 con.beginTrans()
 
 on error resume next
 con.execute sql
 if err <> 0 then
 con.rollbackTrans()
 response.write err.description & "<BR>" & sql
 response.end
 end if
 
 con.commitTrans()
 [/size]
  
  
 

 
any ideas?
 
#1
    webber123456

    • Total Posts : 58
    • Scores: 0
    • Reward points : 0
    • Joined: 9/20/2007
    • Status: offline
    RE: Batch statements. Saturday, June 28, 2008 6:53 AM (permalink)
    0
    try outputting the error first then doing a rollback...
     
    #2
      dodad

      • Total Posts : 3
      • Scores: 0
      • Reward points : 0
      • Joined: 6/26/2008
      • Status: offline
      RE: Batch statements. Monday, June 30, 2008 1:46 AM (permalink)
      0
      I can't get the error.  Thats the problem.  That sql string will execute just fine in SQL Server 2000 through ADO even though the sixth insert statement will error out. 
       
      #3

        Online Bookmarks Sharing: Share/Bookmark

        Jump to:

        Current active users

        There are 0 members and 1 guests.

        Icon Legend and Permission

        • New Messages
        • No New Messages
        • Hot Topic w/ New Messages
        • Hot Topic w/o New Messages
        • Locked w/ New Messages
        • Locked w/o New Messages
        • Read Message
        • Post New Thread
        • Reply to message
        • Post New Poll
        • Submit Vote
        • Post reward post
        • Delete my own posts
        • Delete my own threads
        • Rate post

        2000-2012 ASPPlayground.NET Forum Version 3.9