Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 inserting data is skipping values

Author  Topic 

bciarcia
Starting Member

28 Posts

Posted - 2003-05-07 : 10:17:54
Hey all.. I have an array that splits a form field up and inserts each one as an individual record. My problem is that is seems to be skipping some of the values and I can't figure out why. My code and the values are below. Any help will be appreciated..

thanks..


Dim I
DIM InsSub
if (request.form("sublaw")<>"") then

Dim sublw

sublw = split(Request.Form("sublaw"),", ")


for I = LBound(sublw) to Ubound(sublw)

insSQL = "insert into dbo.SubTopics (Sub_Law,Doc_ID) values ('" & sublw(I) & "'," & New_ID & ")"
Set InsSub = Server.CreateObject("ADODB.Command")
InsSub.ActiveConnection = MM_intrasql1_STRING
InsSub.CommandText = insSQL
InsSub.Execute

next
InsSub.ActiveConnection.Close
Set InSub = nothing

end if



here is the values i am inputing..


Agency
Anti-Trust
Article 9/Mortgage Contracts <----- skipped
Attorney Fees
Banking
Business Torts
Collections
Construction
Construction Contracts <----- skipped
Consumer Protection (93A & CUPA) <----- skipped
Contracts
Damages
Enforcement of Judgments <----- skipped
ERISA
Insurance
Leases
Negligence
Patents/Trademarks
Prejudgment Security
Product Liability
Professional Liability
Sale of Goods(U.C.C. Art. 2) <--------- skipped
Secured Transactions (U.C.C. Art. 9) <--------- skipped
Securities
Torts of Competition
Uniform Commercial Code <--------- skipped
Warranties
White Collar Crime
Miscellaneous

any clues????

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2003-05-07 : 10:31:29
Tip:
for I = LBound(sublw) to Ubound(sublw)

Dim lbound
Dim ubound
lbound = LBound(sublw)
ubound = UBound(sublw)

For i = lbound to ubound

Reason: Lbound and Ubound only evaluated once instead of i times.


Have you tried doing a response.write to see if insSQL is being constructed properly for the skipped values?

Have you thought about escaping single quotes if you have any in the input?

Go to Top of Page

LarsG
Constraint Violating Yak Guru

284 Posts

Posted - 2003-05-07 : 12:21:36
All skipped items are the only being over 20 characters long. How is the column Sub_Law defined?

Go to Top of Page

bciarcia
Starting Member

28 Posts

Posted - 2003-05-07 : 12:29:30
LarsG,

How the @#$% did I miss that?!?!?! Thank you.. That was it..

ValterBorges,

Thanks for your response.. I changed my code to reflect yours.. Everything is running smoothly.. I appreciate both of your help.

Go to Top of Page

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2003-05-07 : 23:02:00
Nice LarsG,

I missed that too.

Go to Top of Page
   

- Advertisement -