Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Batch Update Statement Help

Reply
Thread Tools

Batch Update Statement Help

 
 
bcap
Guest
Posts: n/a
 
      08-28-2009
Hi,

I have written the below update statement and it works fine if there
are multiple records in my recordset, but if there is just one single
record it will not update that one record. Any ideas to what I am
doing wrong or need to do right? =)

dim id
dim xx
if uBound(DID) = 0 then
xx=1
else
xx=0
end if
for id=xx to uBound(DID)
sql_update = "update " & t_maintable & ""
sql_update = sql_update & " SET "',"
sql_update = sql_update & "ConLetDt='" & trim(ConLetDt(id)) &
"',"
sql_update = sql_update & "PID='" & trim(PID(id)) & "',"
sql_update = sql_update & "SID='" & trim(SID(id)) & "',"
sql_update = sql_update & "RespDt='" & trim(RespDt(id)) & "',"
sql_update = sql_update & "TVal='" & trim(TVal(id)) & "',"
sql_update = sql_update & "PSExportDt='" & trim(PSExportDt(id)) &
"',"
sql_update = sql_update & "dShipInd='" & trim(dShipInd(id)) &
"',"
sql_update = sql_update & "ShipRefNo='" & trim(ShipRefNo(id)) &
"'"
sql_update = sql_update & "WHERE DID =" & DID(id)
conn1.Execute sql_update,,129

Thank you in advance!!!!!!!
 
Reply With Quote
 
 
 
 
Adrienne Boswell
Guest
Posts: n/a
 
      08-28-2009
Gazing into my crystal ball I observed bcap <> writing
in news:4e7eddfd-efa3-439f-87ce-555013ce0721
@o21g2000vbl.googlegroups.com:

> Hi,
>
> I have written the below update statement and it works fine if there
> are multiple records in my recordset, but if there is just one single
> record it will not update that one record. Any ideas to what I am
> doing wrong or need to do right? =)
>
> dim id
> dim xx
> if uBound(DID) = 0 then
> xx=1
> else
> xx=0
> end if
> for id=xx to uBound(DID)
> sql_update = "update " & t_maintable & ""
> sql_update = sql_update & " SET "',"
> sql_update = sql_update & "ConLetDt='" & trim(ConLetDt(id)) &
> "',"
> sql_update = sql_update & "PID='" & trim(PID(id)) & "',"
> sql_update = sql_update & "SID='" & trim(SID(id)) & "',"
> sql_update = sql_update & "RespDt='" & trim(RespDt(id)) & "',"
> sql_update = sql_update & "TVal='" & trim(TVal(id)) & "',"
> sql_update = sql_update & "PSExportDt='" & trim(PSExportDt(id)) &
> "',"
> sql_update = sql_update & "dShipInd='" & trim(dShipInd(id)) &
> "',"
> sql_update = sql_update & "ShipRefNo='" & trim(ShipRefNo(id)) &
> "'"
> sql_update = sql_update & "WHERE DID =" & DID(id)
> conn1.Execute sql_update,,129
>
> Thank you in advance!!!!!!!
>


Are you getting an error message? Put a response.write sql_update before
the execute and see what it says. Post back here.

--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share

 
Reply With Quote
 
 
 
 
bcap
Guest
Posts: n/a
 
      08-28-2009
Hi,

Thank you for your relpy. No, I do not get an error message. It just
seems like it does not want to update the record if it is only one
record.

If I have 50 records it could batch 49 of them or even all 50 at one
time, but if I have only 1 record, it seems like it just ignores the
update.

When the record has multiple updates at a time the

uBound = 1
xx = 0

When it is a single record being updated the

uBound = 0
xx = 1

Could this be the cuase of the problem?
 
Reply With Quote
 
Bob Barrows
Guest
Posts: n/a
 
      08-28-2009
bcap wrote:
> Hi,
>
> Thank you for your relpy. No, I do not get an error message. It just
> seems like it does not want to update the record if it is only one
> record.
>
> If I have 50 records it could batch 49 of them or even all 50 at one
> time, but if I have only 1 record, it seems like it just ignores the
> update.
>
> When the record has multiple updates at a time the
>
> uBound = 1
> xx = 0
>
> When it is a single record being updated the
>
> uBound = 0
> xx = 1
>
> Could this be the cuase of the problem?


We can't tell without seeing the sql statement being executed.

--
Microsoft MVP - ASP/ASP.NET - 2004-2007
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
Reply With Quote
 
bcap
Guest
Posts: n/a
 
      08-28-2009
Here is the error message:

Microsoft VBScript runtime error '800a0009'
Subscript out of range: '0'





I realize that if works OK if all fields are populated, but this error
produces if at least one of these fields is NULL
 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      08-28-2009
bcap wrote on 28 aug 2009 in microsoft.public.inetserver.asp.general:

> dim xx
> if uBound(DID) = 0 then
> xx=1
> else
> xx=0
> end if
> for id=xx to uBound(DID)
>


Why not make it simple:

dim id, xx
if uBound(DID) > 0 then
for id = 0 to uBound(DID)
.........
next
end if



--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
Bob Barrows
Guest
Posts: n/a
 
      08-28-2009
bcap wrote:
> Here is the error message:
>
> Microsoft VBScript runtime error '800a0009'
> Subscript out of range: '0'
>
>
>
>
>
> I realize that if works OK if all fields are populated, but this error
> produces if at least one of these fields is NULL


I'm lost. I thought you originally said there was no error message. Let's
see ... yes, you did say this: "No, I do not get an error message"
The symptom I was dealing with was the one where a sql statement was
generated that did not produce the intended results. The only way to deal
with that situation is to discover what the failing sql statement looks like
using Response.Write.

Now you tell me that you are getting an error message. What line of code
raises that error?

And what "fields" are you talking about? All we have seen is a partial block
of vbscript that supposedly loops through what appears to be an array and
generates a string that should contain a sql statement to be executed. More
details please.

--
Microsoft MVP - ASP/ASP.NET - 2004-2007
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Actually, ado.net 2.0 help needed - batch update failing andy6 ASP .Net 2 06-15-2006 04:25 PM
if statement that, when false, skips first statement in its block, executes second? Jay McGavren Java 11 01-16-2006 05:49 PM
How do I do a conditional statement in a constant statement? tkvhdl@gmail.com VHDL 3 12-16-2005 06:13 PM
exec "statement" VS. exec "statement in globals(), locals() Ted Python 1 07-22-2004 08:51 AM
exec "statement" VS. exec "statement" in globals(), locals() tedsuzman Python 2 07-21-2004 08:41 PM



Advertisments
 



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