Tricky Array Problem

1. Senior Member
Join Date
Dec 1969
Posts
521

## Tricky Array Problem

Hi<BR><BR>I am building an availability checker that builds a string in the database that I manipulate using arrays. But it seems to and extra ‘commas’ and numbers. A nice early challenge! Code Below:<BR><BR><BR>Dim arrAges() <BR>Dim str, strDelimiter, accomID, daycount<BR>Dim conn, rs, upSQL, thedate<BR><BR>&#039;-----Get the availability from the database---------------<BR><BR>daycount = request.form ("thedays")<BR>accomID = request.form ("accomID")<BR><BR>Set conn = Server.CreateObject("adodb.connection")<BR>Set rs = Server.CreateObject("ADODB.Recordset")<BR><BR>upSQ L="SELECT availability FROM Accomdescipts WHERE accomid = " & accomID<BR><BR>Conn.open strconnect <BR>RS.open upSQL, Conn, 2, 2 <BR><BR>theavailability = rs("availability")<BR><BR>rs.Close<BR>conn.close<B R>set rs = nothing<BR>set conn = nothing<BR><BR>&#039;-----Increase the array size---------------<BR>thearraysize = 0<BR>For i = 1 to daycount<BR> thedate = request.form(""&i&"")<BR> <BR> if thedate = "" then<BR> hiddenvalue = request.form("hidden"&i)<BR> response.Write "hiddenvalue: " & hiddenvalue &"<BR>"<BR> theavailability = Replace(theavailability, hiddenvalue , "")<BR> else<BR> thearraysize = thearraysize + 1<BR> end if<BR>Next<BR><BR>&#039;-----Create array arrAges---------------<BR>ReDim arrAges(thearraysize)<BR>x = 0<BR><BR>For i = 1 to daycount<BR> thedate = request.form(""&i&"")<BR> isonlist = InStr(1, theavailability, thedate) <BR> if thedate = "" OR isonlist &#062; 0 then<BR> &#039;do nothing<BR> else<BR> x = x + 1<BR> arrAges(x) = thedate<BR> end if<BR>Next<BR><BR>&#039;-----Create array arrAges2---------------<BR>Dim arrAges2<BR>arrAges2 = split(theavailability, ",")<BR><BR>&#039;-----Merge array arrAges & arrAges2 as String: strMerge---------------<BR>strDelimiter = ","<BR>str = join(arrAges, strDelimiter) <BR>str2 = join(arrAges2, strDelimiter) <BR><BR>strMerge = str2 & str<BR><BR>Set conn = Server.CreateObject("adodb.connection")<BR>Set rs = Server.CreateObject("ADODB.Recordset")<BR><BR>upSQ L="Update accomdescipts Set availability= &#039;"&strMerge&"&#039; Where [accomID] = "&accomID&""<BR><BR>Conn.open strconnect <BR>RS.open upSQL, Conn, 2, 2 <BR><BR>set rs = nothing<BR>set conn = nothing<BR>response.redirect "availability.asp?accomID="& accomID &"&themonth="& month(date) &"&theyear="& year(date)<BR><BR>Thanks <BR><BR>Gary

2. Senior Member
Join Date
Dec 1969
Posts
200

## RE: Tricky Array Problem

your code is lenghty. try debugging at every instance your array is populated by response.writing the entire output. that way, you can track down where its happenning and why !

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•