VBScript runtime error '800a0009' - Subscript out of range: '1'

Hi Experts,
I am adding lines on my Classic ASP page then submit to SQL Server database.
For some reason the following error message is returned:

Microsoft VBScript runtime error '800a0009'
Subscript out of range: '1'
/BuildLines_Send.asp, line 39

Please take a look at my code. The error shows up only after I add the SunOff, MonOff, etc. fields that start on line 29, 39 and 40. Without the SunOff, MonOff, TueOff etc. fields the script works fine. Would you please help me solve this problem?
<!-- #include virtual="/DevConn.asp" -->
<%
'declare variables
Dim conn, strSQL, strBidLine

'Set values into variables
strBidLine = request.Form("BidLine")
strStartTime = request.Form("StartTime")
strEndTime = request.Form("EndTime")
strSunOff = request.Form("SunOff")
strMonOff = request.Form("MonOff")
strTueOff = request.Form("TueOff")
strWedOff = request.Form("WedOff")
strThuOff = request.Form("ThuOff")
strFriOff = request.Form("FriOff")
strSatOff = request.Form("SatOff")
strArea = request.Form("Area")
strSubArea = request.Form("SubArea")
strJobTitle = request.Form("JobTitle")
strStatus = request.Form("Status")

'create SQL string for inserting data into database
strSQL = "INSERT INTO CSBidOct2013 (BidLine, StartTime, EndTime, SunOff, MonOff, TueOff, WedOff, ThuOff, FriOff, SatOff, Area, SubArea, JobTitle, Status) VALUES "

Dim arr_BidLine, arr_StartTime, arr_EndTime, arr_SunOff, arr_MonOff, arr_TueOff, arr_WedOff, arr_ThuOff, arr_FriOff, arr_SatOff, arr_count
arr_BidLine = Split(strBidLine, ", ")
arr_StartTime = Split(strStartTime, ", ")
arr_EndTime = Split(strEndTime, ", ")
arr_SunOff = Split(strSunOff, ", ")
arr_MonOff = Split(strMonOff, ", ")
arr_TueOff = Split(strTueOff, ", ")
arr_WedOff = Split(strWedOff, ", ")
arr_ThuOff = Split(strThuOff, ", ")
arr_FriOff = Split(strFriOff, ", ")
arr_SatOff = Split(strSatOff, ", ")

For arr_count = 1 To UBound(arr_BidLine) ' skip the first one!
	If arr_count > 1 Then strSQL = strSQL & ","
	strSQL = strSQL & "('"& arr_BidLine(arr_count) &"','"& arr_StartTime(arr_count) &"','"& arr_EndTime(arr_count) &"','"& arr_SunOff(arr_count) &"','"& arr_MonOff(arr_count) &"','"& arr_TueOff(arr_count) &"','"& arr_WedOff(arr_count) &"','"& arr_ThuOff(arr_count) &"','"& arr_FriOff(arr_count) &"','"& arr_SatOff(arr_count) &"','"& strArea &"','"& strSubArea &"','"& strJobTitle &"','"& strStatus &"')"
	tableRows = tableRows	& "<tr><td align='center'>" & arr_BidLine(arr_count) & "</td><td align='center'>" & arr_StartTime(arr_count) & "</td><td align='center'>" & arr_EndTime(arr_count) & "</td><td align='center'>" & arr_SunOff(arr_count) & "</td><td align='center'>" & arr_MonOff(arr_count) & "</td><td align='center'>" & arr_TueOff(arr_count) & "</td><td align='center'>" & arr_WedOff(arr_count) & "</td><td align='center'>" & arr_ThuOff(arr_count) & "</td><td align='center'>" & arr_FriOff(arr_count) & "</td><td align='center'>" & arr_SatOff(arr_count) & "</td></tr> "
Next

'now add data with Execute() method
conn.Execute(strSql)

'close connection object
conn.Close
Set conn = Nothing

'Redirect to the completed.asp page
Response.Redirect "EditAllLines.asp"

%>

Open in new window

romsomIT DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Should the count start at zero and not one?  

or on line 38 where you have

If arr_count > 1 Then strSQL = strSQL & ","

I don't see where you are checking if arr_SunOff = Split(strSunOff, ", ") has any data?
0
romsomIT DeveloperAuthor Commented:
When I change the count to 0 I get this error message:
Subscript out of range: '0'

Please see a working example.
The problem is that I need to add the SunOff, MonOff, TueOff, WedOff, ThuOff, FriOff, SatOff fields too, and when I try to add them I get an error message.
This is the version which doesn't display errors:
<!-- #include virtual="/DevConn.asp" -->
<%

'declare variables
Dim conn, strSQL, strBidLine

'Set values into variables
strBidLine = request.Form("BidLine")
strStartTime = request.Form("StartTime")
strEndTime = request.Form("EndTime")
strSunOff = request.Form("SunOff")
strMonOff = request.Form("MonOff")
strTueOff = request.Form("TueOff")
strWedOff = request.Form("WedOff")
strThuOff = request.Form("ThuOff")
strFriOff = request.Form("FriOff")
strSatOff = request.Form("SatOff")
strArea = request.Form("Area")
strSubArea = request.Form("SubArea")
strJobTitle = request.Form("JobTitle")
strStatus = request.Form("Status")

'create SQL string for inserting data into database
strSQL = "INSERT INTO CSBidOct2013 (BidLine, StartTime, EndTime, SunOff, MonOff, TueOff, WedOff, ThuOff, FriOff, SatOff, Area, SubArea, JobTitle, Status) VALUES "

Dim arr_BidLine, arr_StartTime, arr_EndTime, arr_count
arr_BidLine = Split(strBidLine, ", ")
arr_StartTime = Split(strStartTime, ", ")
arr_EndTime = Split(strEndTime, ", ")


For arr_count = 1 To UBound(arr_BidLine) ' skip the first one!
	If arr_count > 1 Then strSQL = strSQL & ","
	strSQL = strSQL & "('"& arr_BidLine(arr_count) &"','"& arr_StartTime(arr_count) &"','"& arr_EndTime(arr_count) &"','"& strSunOff &"','"& strMonOff &"','"& strTueOff &"','"& strWedOff &"','"& strThuOff &"','"& strFriOff &"','"& strSatOff &"','"& strArea &"','"& strSubArea &"','"& strJobTitle &"','"& strStatus &"')"
	tableRows = tableRows	& "<tr><td align='center'>" & arr_BidLine(arr_count) & "</td><td align='center'>" & arr_StartTime(arr_count) & "</td><td align='center'>" & arr_EndTime(arr_count) & "</td></tr> "
Next

'now add data with Execute() method
conn.Execute(strSql)

'close connection object
conn.Close
Set conn = Nothing


'Redirect to the completed.asp page
Response.Redirect "EditAllLines.asp"

%>

Open in new window


I can't see why adding the SunOff, MonOff, TueOff, WedOff, ThuOff, FriOff, SatOff returns the error message.
0
QuinnDexCommented:
make sure you are giving MonOff etc. default data, then see if that works
0
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

romsomIT DeveloperAuthor Commented:
Right now I send the data like this:
<input name="SunOff" value="ü" type="checkbox">
When users check the box it's supposed to send the ü character to the database. How can I give a default data to the checkbox?
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
First, I would at least do a basic data clean function and never trust data coming from a querystring or form field.   I have added a basic clean function to start.  Next, I test if there is data after cleaning.  If there is, then set the field strSunOff to the form field.  If not, then set it to some default value.  In this case, I just used x.  

' ----- basic clean function ------
function clean(it)
     it=replace(it,"'","") 'remove single quote
     it=replace(it,"<","") 'remove les then
     it=replace(it,">","") 'remove greater then
end function

if clean(request.Form("SunOff"))<>"" then '  make sure we have data
     strSunOff = clean(request.Form("SunOff"))
     else
     strSunOff = "x" ' default value. Actual value may be "ü" 
end if
arr_SunOff=split(strSunOff,",") ' no you will always have an array the size of 0 (1).

Open in new window


I noticed in your code you are using arr_SunOff = Split(strSunOff, ", ") where there is a space after the comma.  If you are expecting multiple values comma delimited, you don't need the space after the comma.  Perhaps that is the real issue.  If your data looks like;

str_X="one,two,three"
arr_X=spit(str_X,", ")

then arr_X(0) will still be "one,two,three" and there will be no arr_X(1) or arr_X(2).

If you changed arr_X=spit(str_X,", ")  to arr_X=spit(str_X,",") then you will have;
arr_X(0)="one"
arr_X(1)="two"
arr_X(2)="three"
0
romsomIT DeveloperAuthor Commented:
I've removed the spaces and now my code looks like this:
<!-- #include virtual="/DevConn.asp" -->
<%
'declare variables
Dim conn, strSQL, strBidLine

'Set values into variables
strBidLine = request.Form("BidLine")
strStartTime = request.Form("StartTime")
strEndTime = request.Form("EndTime")
strSunOff = request.Form("SunOff")
strMonOff = request.Form("MonOff")
strTueOff = request.Form("TueOff")
strWedOff = request.Form("WedOff")
strThuOff = request.Form("ThuOff")
strFriOff = request.Form("FriOff")
strSatOff = request.Form("SatOff")
strArea = request.Form("Area")
strSubArea = request.Form("SubArea")
strJobTitle = request.Form("JobTitle")
strStatus = request.Form("Status")

'create SQL string for inserting data into database
strSQL = "INSERT INTO CSBidOct2013 (BidLine, StartTime, EndTime, SunOff, MonOff, TueOff, WedOff, ThuOff, FriOff, SatOff, Area, SubArea, JobTitle, Status) VALUES "

Dim arr_BidLine, arr_StartTime, arr_EndTime, arr_SunOff, arr_MonOff, arr_TueOff, arr_WedOff, arr_ThuOff, arr_FriOff, arr_SatOff, arr_count
arr_BidLine = Split(strBidLine,",")
arr_StartTime = Split(strStartTime,",")
arr_EndTime = Split(strEndTime,",")
arr_SunOff = Split(strSunOff,",")
arr_MonOff = Split(strMonOff,",")
arr_TueOff = Split(strTueOff,",")
arr_WedOff = Split(strWedOff,",")
arr_ThuOff = Split(strThuOff,",")
arr_FriOff = Split(strFriOff,",")
arr_SatOff = Split(strSatOff,",")

For arr_count = 0 To UBound(arr_BidLine) ' skip the first one!
	If arr_count > 1 Then strSQL = strSQL & ","
	strSQL = strSQL & "('"& arr_BidLine(arr_count) &"','"& arr_StartTime(arr_count) &"','"& arr_EndTime(arr_count) &"','"& arr_SunOff(arr_count) &"','"& arr_MonOff(arr_count) &"','"& arr_TueOff(arr_count) &"','"& arr_WedOff(arr_count) &"','"& arr_ThuOff(arr_count) &"','"& arr_FriOff(arr_count) &"','"& arr_SatOff(arr_count) &"','"& strArea &"','"& strSubArea &"','"& strJobTitle &"','"& strStatus &"')"
	tableRows = tableRows	& "<tr><td align='center'>" & arr_BidLine(arr_count) & "</td><td align='center'>" & arr_StartTime(arr_count) & "</td><td align='center'>" & arr_EndTime(arr_count) & "</td><td align='center'>" & arr_SunOff(arr_count) & "</td><td align='center'>" & arr_MonOff(arr_count) & "</td><td align='center'>" & arr_TueOff(arr_count) & "</td><td align='center'>" & arr_WedOff(arr_count) & "</td><td align='center'>" & arr_ThuOff(arr_count) & "</td><td align='center'>" & arr_FriOff(arr_count) & "</td><td align='center'>" & arr_SatOff(arr_count) & "</td></tr> "
Next

'now add data with Execute() method
conn.Execute(strSql)

'close connection object
conn.Close
Set conn = Nothing

'Redirect to the completed.asp page
Response.Redirect "EditAllLines.asp"

%>

Open in new window

The error message changed to this:
Microsoft VBScript runtime error '800a0009'
Subscript out of range: '0'
/BuildLines_Send.asp, line 39
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Did you try my other code?

Also please try adding at the very top of your page
<%
if request.form<>"" then
response.write request.form&"<br><br>"
for each x in Request.Form
        Response.Write("<br>" & x & " = " & Request.Form(x))
 next

response.end()
end if

%>
0
romsomIT DeveloperAuthor Commented:
Thank you Padas. I've placed your code to the very top of my page then I submitted two rows. This is what was returned:

Area=MOBILITY&SubArea=ADMIN&JobTitle=CCR&Status=FULL&ID=0&BidLine=&StartTime=&EndTime=&ID=1&BidLine=001&StartTime=08%3A00&EndTime=16%3A30&SunOff=%FC&MonOff=%FC&ID=2&BidLine=002&StartTime=10%3A00&EndTime=18%3A30&TueOff=%FC&WedOff=%FC&Submit=Submit


Area = MOBILITY
BidLine = , 001, 002
EndTime = , 16:30, 18:30
SubArea = ADMIN
StartTime = , 08:00, 10:00
TueOff = ü
JobTitle = CCR
Status = FULL
ID = 0, 1, 2
MonOff = ü
Submit = Submit
SunOff = ü
WedOff = ü
0
romsomIT DeveloperAuthor Commented:
When I submit one line the following is returned:

Area=MOBILITY&SubArea=ADMIN&JobTitle=CCR&Status=FULL&ID=0&BidLine=&StartTime=&EndTime=&ID=1&BidLine=9999&StartTime=12%3A30&EndTime=21%3A00&SunOff=%FC&MonOff=%FC&Submit=Submit


Area = MOBILITY
BidLine = , 9999
EndTime = , 21:00
SubArea = ADMIN
StartTime = , 12:30
JobTitle = CCR
Status = FULL
ID = 0, 1
MonOff = ü
Submit = Submit
SunOff = ü

I've noticed that there is no comma in front of the ü of MonOff and SunOff. I think there should be a comma before the ü because those are the values that change in each line. Area, SubArea, JobTitle and Status are supposed to be the same in each line.  Only BidLine, StartTime, EndTime, SunOff, etc. are changed based on what users type in before they submit the form.
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
I would work on a few things.  First on line 39 try and isolate what the real problem is.

You have
	strSQL = strSQL & "('"& arr_BidLine(arr_count) &"','"& arr_StartTime(arr_count) &"','"& arr_EndTime(arr_count) &"','"& arr_SunOff(arr_count) &"','"& arr_MonOff(arr_count) &"','"& arr_TueOff(arr_count) &"','"& arr_WedOff(arr_count) &"','"& arr_ThuOff(arr_count) &"','"& arr_FriOff(arr_count) &"','"& arr_SatOff(arr_count) &"','"& strArea &"','"& strSubArea &"','"& strJobTitle &"','"& strStatus &"')"

Open in new window

Try Remove all the arr_MonOff fields
	strSQL = strSQL & "('"& arr_BidLine(arr_count) &"','"& arr_StartTime(arr_count) &"','"& arr_EndTime(arr_count)  &"','"& strArea &"','"& strSubArea &"','"& strJobTitle &"','"& strStatus &"')"

Open in new window

If that is not the problem try removing each of the other fields until you don't get an error. This will help us know exactly where the problem is.

Notice in the code returned you have some fields that start with nothing.   The 3 fields below all start with a comma and that means array(0) probably errors.
BidLine = , 001, 002
EndTime = , 16:30, 18:30
StartTime = , 08:00, 10:00

Another thing you can do is manually add these 3 arrays to test if it is data like;
BidLine =  001, 002
EndTime = 16:30, 18:30
StartTime =  08:00, 10:00
0
romsomIT DeveloperAuthor Commented:
I've removed all fields until I didn't get an error. The following script submitted the Area, SubArea, JobTitle, Status, BidLine, StartTime, EndTime columns to the database without problems:
<!-- #include virtual="/DevConn.asp" -->
<%
'declare variables
Dim conn, strSQL, strBidLine

'Set values into variables
strBidLine = request.Form("BidLine")
strStartTime = request.Form("StartTime")
strEndTime = request.Form("EndTime")
strSunOff = request.Form("SunOff")
strMonOff = request.Form("MonOff")
strTueOff = request.Form("TueOff")
strWedOff = request.Form("WedOff")
strThuOff = request.Form("ThuOff")
strFriOff = request.Form("FriOff")
strSatOff = request.Form("SatOff")
strArea = request.Form("Area")
strSubArea = request.Form("SubArea")
strJobTitle = request.Form("JobTitle")
strStatus = request.Form("Status")

'create SQL string for inserting data into database
strSQL = "INSERT INTO CSBidOct2013 (BidLine, StartTime, EndTime, SunOff, MonOff, TueOff, WedOff, ThuOff, FriOff, SatOff, Area, SubArea, JobTitle, Status) VALUES "

Dim arr_BidLine, arr_StartTime, arr_EndTime, arr_count
arr_BidLine = Split(strBidLine,",")
arr_StartTime = Split(strStartTime,",")
arr_EndTime = Split(strEndTime,",")

For arr_count = 1 To UBound(arr_BidLine) ' skip the first one!
	If arr_count > 1 Then strSQL = strSQL & ","
	strSQL = strSQL & "('"& arr_BidLine(arr_count) &"','"& arr_StartTime(arr_count) &"','"& arr_EndTime(arr_count) &"','"& strSunOff &"','"& strMonOff &"','"& strTueOff &"','"& strWedOff &"','"& strThuOff &"','"& strFriOff &"','"& strSatOff &"','"& strArea &"','"& strSubArea &"','"& strJobTitle &"','"& strStatus &"')"
	tableRows = tableRows	& "<tr><td align='center'>" & arr_BidLine(arr_count) & "</td><td align='center'>" & arr_StartTime(arr_count) & "</td><td align='center'>" & arr_EndTime(arr_count) & "</td></tr> "
Next

'now add data with Execute() method
conn.Execute(strSql)

'close connection object
conn.Close
Set conn = Nothing

'Redirect to the completed.asp page
Response.Redirect "EditAllLines.asp"

%>

Open in new window


When I'm trying to add any other field, e.g. SunOff, I get the error message.
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
The issue is the SunOff array seems to always have only only one row of data.  As soon as you call arr_SunOff(arr_count) when arr_count has a value other then 0 it will fail and probably also if SunOff is non existant.
0
romsomIT DeveloperAuthor Commented:
I'm afraid I didn't explain what my goal is.
I have 3 pages.
On Page One I have 4 dropdown menus where I select Area, SubArea, JobTitle, Status.
<table>
<tr>
<td>Work Area</td>
<td>Sub Area</td>
<td>JobTitle</td>
<td>Status</td>
</tr>
<tr><td>
<select name="Area">
<option value='CHINESE'>CHINESE</option>
<option value='FRENCH'>FRENCH</option>
<option value='GERMAN'>GERMAN</option>
<option value='HEBREW'>HEBREW</option>
</td><td>
<select name="SubArea">
<option value='ADMIN'>ADMIN</option>
<option value='ALL'>ALL</option>
<option value='STATION'>STATION</option>
</td><td>
<select name="JobTitle">
<option value="VENDOR">VENDOR</option>
<option value="SUPERVISOR">SUPERVISOR</option>
<option value="ASSISTANT">ASSISTANT</option>
</td><td>
<select name="Status">
<option value="FULL">FULL</option>
<option value="PART">PART</option>
</td>
</tr>
</table>

Open in new window

This information is sent to Page Two, where the lines are added. The Area, SubArea, JobTitle, Status stays the same in each line, only the StartTime, EndTime, SunOff, etc. is different in each line, depending what the users enter:
<table class="dynatable">
<thead>
<tr>
<td align="center"><b>ID</b></td>
<td align="center">BidLine</td>
<td align="center">Start</td>
<td align="center">End</td>
<td align="center">S</td>
<td align="center">M</td>
<td align="center">T</td>
<td align="center">W</td>
<td align="center">T</td>
<td align="center">F</td>
<td align="center">S</td>
<td><button class="add">Add Bid Line</button></td>
</tr>
</thead>
<tbody>
<tr class="prototype">
<td><input type="text" name="ID" value="0" class="ID" /></td>
<td><input type="text" name="BidLine" style="text-align:center" size="5" maxlength="5" /></td>
<td><input type="text" name="StartTime" id="StartTime.[1]" /></td>
<td><input type="text" name="EndTime" id="EndTime.[1]" /></td>
<td><input name="SunOff" value="x" type="checkbox" class="one"></td>
<td><input name="MonOff" value="x" type="checkbox" class="one"></td>
<td><input name="TueOff" value="x" type="checkbox" class="one"></td>
<td><input name="WedOff" value="x" type="checkbox" class="one"></td>
<td><input name="ThuOff" value="x" type="checkbox" class="one"></td>
<td><input name="FriOff" value="x" type="checkbox" class="one"></td>
<td><input name="SatOff" value="x" type="checkbox" class="one"></td>
<td><button class="remove">Remove Line</button>
</tr>
</table>

Open in new window

Finally Page Three, with which I have a problem, is supposed to send the lines to the database.
Any other solution would solve my problem, as long as users are able to select different hours and days off for each line that is added on Page Two.
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Each time you click Add Bid Line button, you should be adding a row of data to your db.

tblWorkArea
ID
ContactID
Work Area
Sub Area      
JobTitle      
Status

tblWordAreaBidLine
ID
WorkAreaID
BidLine
Start
Stop
Days

For the Days field, that could look something like Sun,Mon,Tue,Wed,Thr,Fri,Sat OR 1,2,3,4,5,6,7.  To do that, the checkbox's would look like
<td><input name="DayOFF" value="Sun" type="checkbox" class="one"></td>
<td><input name="DayOFF" value="Mon" type="checkbox" class="one"></td>
<td><input name="DayOFF" value="Tue" type="checkbox" class="one"></td>
<td><input name="DayOFF" value="Wed" type="checkbox" class="one"></td>
<td><input name="DayOFF" value="Thr" type="checkbox" class="one"></td>
<td><input name="DayOFF" value="Fri" type="checkbox" class="one"></td>
<td><input name="DayOFF" value="Sat" type="checkbox" class="one"></td>

Open in new window

When a group of form fields have the same name, they are sent as comma separated.
0
romsomIT DeveloperAuthor Commented:
I forgot to mention that I have only one table in the database. The values from Page Two are taken to Page Three like this:

<form name="formName" action="BuildLines_Send.asp" method="POST">
<table><tr>
<td><b>Work Area</b></td>
<td><b>Sub Area</b></td>
<td><b>JobTitle</b></td>
<td><b>Status</b></td>
</tr>
<tr>
<td><input type="text" name="Area" value="<%=Request.Form("Area")%>" /></td>
<td><input type="text" name="SubArea" value="<%=Request.Form("SubArea")%>" /></td>
<td><input type="text" name="JobTitle" value="<%=Request.Form("JobTitle")%>" /></td>
<td><input type="text" name="Status" value="<%=Request.Form("Status")%>" /></td>
</tr>
</table>

<br />

<table>
<tr>
<td>Work Area</td>
<td>Sub Area</td>
<td>JobTitle</td>
<td>Status</td>
</tr>
<tr><td>
<select name="Area">
<option value='CHINESE'>CHINESE</option>
<option value='FRENCH'>FRENCH</option>
<option value='GERMAN'>GERMAN</option>
<option value='HEBREW'>HEBREW</option>
</td><td>
<select name="SubArea">
<option value='ADMIN'>ADMIN</option>
<option value='ALL'>ALL</option>
<option value='STATION'>STATION</option>
</td><td>
<select name="JobTitle">
<option value="VENDOR">VENDOR</option>
<option value="SUPERVISOR">SUPERVISOR</option>
<option value="ASSISTANT">ASSISTANTCCR</option>
</td><td>
<select name="Status">
<option value="FULL">FULL</option>
<option value="PART">PART</option>
</td>
</tr>
</table>

<input type="submit" name="Submit" value="Submit" />
0
romsomIT DeveloperAuthor Commented:
I mean the lower part is on Page One, then Page Two is sending
<td><input type="text" name="Area" value="<%=Request.Form("Area")%>" /></td>
to Page Three

Sorry for the confusion
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
The main point is each time you are looping, you are increasing arr_count.  If the array has 4 rows but SunOff only has one, then as soon as arr_count gets to 1, arr_SunOff(arr_count) will fail because it only has one row of data.

For arr_count = 1 To UBound(arr_BidLine) ' skip the first one!
	If arr_count > 1 Then strSQL = strSQL & ","
	strSQL = strSQL & "('"& arr_BidLine(arr_count) &"','"& arr_StartTime(arr_count) &"','"& arr_EndTime(arr_count) &"','"& arr_SunOff(arr_count) &"','"& arr_MonOff(arr_count) &"','"& arr_TueOff(arr_count) &"','"& arr_WedOff(arr_count) &"','"& arr_ThuOff(arr_count) &"','"& arr_FriOff(arr_count) &"','"& arr_SatOff(arr_count) &"','"& strArea &"','"& strSubArea &"','"& strJobTitle &"','"& strStatus &"')"
	tableRows = tableRows	& "<tr><td align='center'>" & arr_BidLine(arr_count) & "</td><td align='center'>" & arr_StartTime(arr_count) & "</td><td align='center'>" & arr_EndTime(arr_count) & "</td><td align='center'>" & arr_SunOff(arr_count) & "</td><td align='center'>" & arr_MonOff(arr_count) & "</td><td align='center'>" & arr_TueOff(arr_count) & "</td><td align='center'>" & arr_WedOff(arr_count) & "</td><td align='center'>" & arr_ThuOff(arr_count) & "</td><td align='center'>" & arr_FriOff(arr_count) & "</td><td align='center'>" & arr_SatOff(arr_count) & "</td></tr> "
Next

Open in new window

0
QuinnDexCommented:
if SunnOff,MonOff etc are not adding a comma between values then  the split will have nothing to split against so everything will be in the first value 0 which you skip past in your code
0
romsomIT DeveloperAuthor Commented:
I think we are very close to the solution. The code below is perfect, it works exactly how it's supposed to work:
<!-- #include virtual="/DevConn.asp" -->
<%

'declare variables
Dim conn, strSQL, strBidLine, strStartTime, strEndTime, strSunOff, strArea, strSubArea, strJobTitle, strStatus

'Set values into variables
strBidLine = request.Form("BidLine")
strStartTime = request.Form("StartTime")
strEndTime = request.Form("EndTime")
strSunOff = request.Form("SunOff")
strMonOff = request.Form("MonOff")
strTueOff = request.Form("TueOff")
strWedOff = request.Form("WedOff")
strThuOff = request.Form("ThuOff")
strFriOff = request.Form("FriOff")
strSatOff = request.Form("SatOff")
strArea = request.Form("Area")
strSubArea = request.Form("SubArea")
strJobTitle = request.Form("JobTitle")
strStatus = request.Form("Status")

'create SQL string for inserting data into database
strSQL = "INSERT INTO CSBidOct2013 (BidLine, StartTime, EndTime, SunOff, MonOff, TueOff, WedOff, ThuOff, FriOff, SatOff, Area, SubArea, JobTitle, Status) VALUES "

Dim arr_BidLine, arr_StartTime, arr_EndTime, arr_SunOff, arr_MonOff, arr_TueOff, arr_WedOff, arr_ThuOff, arr_FriOff, arr_SatOff, arr_count
arr_BidLine = Split(strBidLine, ", ")
arr_StartTime = Split(strStartTime, ", ")
arr_EndTime = Split(strEndTime, ", ")
arr_SunOff = Split(strSunOff, ", ")
arr_MonOff = Split(strMonOff, ", ")
arr_TueOff = Split(strTueOff, ", ")
arr_WedOff = Split(strWedOff, ", ")
arr_ThuOff = Split(strThuOff, ", ")
arr_FriOff = Split(strFriOff, ", ")
arr_SatOff = Split(strSatOff, ", ")

For arr_count = 1 To UBound(arr_BidLine) ' skip the first one!
	If arr_count > 1 Then strSQL = strSQL & ","
	strSQL = strSQL & "('"& arr_BidLine(arr_count) &"','"& arr_StartTime(arr_count) &"','"& arr_EndTime(arr_count) &"','"& arr_SunOff(arr_count) &"','"& arr_MonOff(arr_count) &"','"& arr_TueOff(arr_count) &"','"& arr_WedOff(arr_count) &"','"& arr_ThuOff(arr_count) &"','"& arr_FriOff(arr_count) &"','"& arr_SatOff(arr_count) &"','"& strArea &"','"& strSubArea &"','"& strJobTitle &"','"& strStatus &"')"
	tableRows = tableRows	& "<tr><td align='center'>" & arr_BidLine(arr_count) & "</td><td align='center'>" & arr_StartTime(arr_count) & "</td><td align='center'>" & arr_EndTime(arr_count) & "</td><td align='center'>" & arr_SunOff(arr_count) & "</td><td align='center'>" & arr_MonOff(arr_count) & "</td><td align='center'>" & arr_TueOff(arr_count) & "</td><td align='center'>" & arr_WedOff(arr_count) & "</td><td align='center'>" & arr_ThuOff(arr_count) & "</td><td align='center'>" & arr_FriOff(arr_count) & "</td><td align='center'>" & arr_SatOff(arr_count) & "</td></tr> "
Next

'now add data with Execute() method
conn.Execute(strSql)

'close connection object
conn.Close
Set conn = Nothing


'Redirect to the completed.asp page
Response.Redirect "EditAllLines.asp"

%>

Open in new window

The problem is with the checkboxes.
I've uses textboxes instead and typed the ü character in them for the days off.
I could submit the data without problems. This is how they look now:
                              <td><input type="text" name="SunOff" /></td>
                              <td><input type="text" name="MonOff" /></td>
                              <td><input type="text" name="TueOff" /></td>
                              <td><input type="text" name="WedOff" /></td>
                              <td><input type="text" name="ThuOff" /></td>
                              <td><input type="text" name="FriOff" /></td>
                              <td><input type="text" name="SatOff" /></td>
The problem is that I need to use checkboxes which when checked, send the ü character to the database. How can I do that without getting the error?
0
romsomIT DeveloperAuthor Commented:
It is also working if I use a dropdown:
<td><select name="SunOff" style="background-color:#fdedb9" class="one">
<option></option>
<option value="ü">DayOff</option>
</select></td>
0
QuinnDexCommented:
set the char you want if checkbox ticked

if  request.Form("SunOff") then

strSunOff = "ü"

end if
0
romsomIT DeveloperAuthor Commented:
Where do I have to place this in my code?
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
I have already suggested that.  Did you try?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
romsomIT DeveloperAuthor Commented:
I'm not sure how to do it
0
romsomIT DeveloperAuthor Commented:
Got it, thank you very much for your help and patience!
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
The reason it works for a drop down is even if you choose <option></option> there is still data.  If you go back to the code where I asked you to do a response.write for the entire form, you will notice you only have 3 days.

MonOff = ü
SunOff = ü
WedOff = ü

If you do the same but this time use a drop down, you will have all 7 days.

If you go back to this answer http:a39568466 you will see there will always be data for each of the SunOff fields.   The key is if you want to use a checkbox will be to make sure you have some type of default data if the data does not come through via the check box.  The reason is, the checkbox will only show up in the request object if it is checked.  If it is not checked, it will not show up in the request object.

Please remember to clean your data.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.