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)
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?
|
|
|
|
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)
try outputting the error first then doing a rollback...
|
|
|
|
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)
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.
|
|
|
|