By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,230 Members | 2,471 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,230 IT Pros & Developers. It's quick & easy.

Microsoft VBScript compilation error '800a0400'

P: 6
I can't figure out why I am getting error: Microsoft VBScript compilation '800a0400'

Expand|Select|Wrap|Line Numbers
  1. SET MyRecordSet = SERVER.CREATEOBJECT("ADODB.RECORDSET")
  2. MySQL = "SELECT * FROM ShipSummary (NOLOCK) where ShipDate = DateDiff(d, 0, GetDate()+1)"
  3. MyRecordSet.OPEN MySQL, XXXXXX
  4. if not MyRecordSet.eof then
  5. MyArray = MyRecordSet.GETROWS()
  6. MyRecordSet.CLOSE
  7. FOR MyCursor = LBOUND(MyArray,2) TO UBOUND(MyArray,2)
  8. body = body + "<TR><TD BGCOLOR=""" & SHADE & """><B>" & "&nbsp;</TD><TD BGCOLOR=""" & SHADE & """><B>" & "</TD><TD BGCOLOR=""" & SHADE & """><B>" & 
  9. "&nbsp;</TD><TD COLSPAN=4 BGCOLOR=""" & SHADE & """><B>"& MyArray(0,MyCursor) & "</TD><TD ALIGN=""CENTER"" BGCOLOR=""" & SHADE & """><B>" & 
  10. MyArray(1,MyCursor) & "</TD><TD ALIGN=""CENTER"" BGCOLOR=""" & SHADE & """><B>" & MyArray(2,MyCursor) & "</TD><TD ALIGN=""CENTER"" BGCOLOR=""" & SHADE & 
  11. """><B>" & MyArray(3,MyCursor) & "</TD><TD ALIGN=""CENTER"" BGCOLOR=""" & SHADE & """><B>" & MyArray(4,MyCursor) & "</TD><TD BGCOLOR=""" & SHADE & """>"& 
  12. "</TD><TD ALIGN=""CENTER"" BGCOLOR=""" & SHADE & """></TD></TR>" & vbcrlf
  13. END IF  ....line 61
  14.  
Microsoft VBScript compilation error '800a0400'
Expected statement
/reports/ShipSummary.asp, line 61

END IF^


Can someone help me out or at least point me in the right direction?
Oct 17 '07 #1
Share this Question
Share on Google+
5 Replies


codegecko
Expert 100+
P: 533
I can't figure out why I am getting error: Microsoft VBScript compilation '800a0400'

Expand|Select|Wrap|Line Numbers
  1. SET MyRecordSet = SERVER.CREATEOBJECT("ADODB.RECORDSET")
  2. MySQL = "SELECT * FROM ShipSummary (NOLOCK) where ShipDate = DateDiff(d, 0, GetDate()+1)"
  3. MyRecordSet.OPEN MySQL, XXXXXX
  4. if not MyRecordSet.eof then
  5. MyArray = MyRecordSet.GETROWS()
  6. MyRecordSet.CLOSE
  7. FOR MyCursor = LBOUND(MyArray,2) TO UBOUND(MyArray,2)
  8. body = body + "<TR><TD BGCOLOR=""" & SHADE & """><B>" & "&nbsp;</TD><TD BGCOLOR=""" & SHADE & """><B>" & "</TD><TD BGCOLOR=""" & SHADE & """><B>" & 
  9. "&nbsp;</TD><TD COLSPAN=4 BGCOLOR=""" & SHADE & """><B>"& MyArray(0,MyCursor) & "</TD><TD ALIGN=""CENTER"" BGCOLOR=""" & SHADE & """><B>" & 
  10. MyArray(1,MyCursor) & "</TD><TD ALIGN=""CENTER"" BGCOLOR=""" & SHADE & """><B>" & MyArray(2,MyCursor) & "</TD><TD ALIGN=""CENTER"" BGCOLOR=""" & SHADE & 
  11. """><B>" & MyArray(3,MyCursor) & "</TD><TD ALIGN=""CENTER"" BGCOLOR=""" & SHADE & """><B>" & MyArray(4,MyCursor) & "</TD><TD BGCOLOR=""" & SHADE & """>"& 
  12. "</TD><TD ALIGN=""CENTER"" BGCOLOR=""" & SHADE & """></TD></TR>" & vbcrlf
  13. END IF  ....line 61
  14.  
Microsoft VBScript compilation error '800a0400'
Expected statement
/reports/ShipSummary.asp, line 61

END IF^


Can someone help me out or at least point me in the right direction?
Hi char,

You forgot to add Next above your End If.

Best regards,

medicineworker
Oct 18 '07 #2

P: 6
I added the "NEXT" before my "END IF" and now it brings me back to the original error to let me know that no records are found.

"ADODB.Recordset error '800a0bcd'

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

How can I get pass this error and get the records that are available to display?
Oct 18 '07 #3

jhardman
Expert 2.5K+
P: 3,405
Which line is giving the recordset error? It is likely that you are getting an error because your query isn't returning any records.

If you will allow it, in my opinion, it makes more sense to loop thru the recordset itself rather than dumping the rs into an array and looping thru that, although I realize that you may have reason to do it that way. This is how my code would look:
Expand|Select|Wrap|Line Numbers
  1. MyRecordSet.OPEN MySQL, XXXXXX
  2. do until myRecordSet.eof %>
  3.    <TR><TD BGCOLOR="<%=SHADE%>"> </TD><TD 
  4.    BGCOLOR="<%=shade%>"> </TD><TD BGCOLOR="<%=shade%>"> </TD>
  5.    <TD COLSPAN=4 BGCOLOR="<%=SHADE%>" 
  6.    ><B><%=MyRecordSet(0)%></b></TD><TD ALIGN="CENTER" 
  7.    BGCOLOR="<%=SHADE%>"><B><%=MyRecordSet(1)%></b></TD>
  8.    <TD ALIGN="CENTER" BGCOLOR="<%=SHADE%>"
  9.    ><B><%=MyRecordSet(2)%></b></TD><TD ALIGN="CENTER"
  10.    BGCOLOR="<%=SHADE%>"><B><%=MyRecordSet(3)%></b></TD><TD
  11.    ALIGN="CENTER" BGCOLOR="<%=SHADE%>"
  12.    ><B><%=MyRecordSet(4)%></b></TD><TD BGCOLOR="<%=SHADE%>"
  13.    ></TD><TD ALIGN="CENTER" BGCOLOR="<%=SHADE%>"></TD></TR>
  14.    <%
  15.    myRecordSet.movenext
  16. loop
There is still room for improvement in this code, for example a simple css style declaration would eliminate having to redefine the style on each of these table cells. Also, the individual fields of the db could be looped through like this:
Expand|Select|Wrap|Line Numbers
  1. for each x in myRecordSet.fields ' or for x = 0 to 4 %>
  2.    <TD COLSPAN=4 BGCOLOR="<%=SHADE%>" 
  3.    ><B><%=MyRecordSet(x)%></b></TD>
  4. <%
  5. next 
Does this make sense?

Jared
Oct 18 '07 #4

markrawlingson
Expert 100+
P: 346
I'm constantly puzzled when I see people setting the bgcolor attribute of every single <td> tag - even setting the background-color attribute of the td tag in a stylesheet is puzzling. Why? Set the bgcolor of your <tr> tag and it will cascade across all of your <td> tags automatically. the only reason you'd want to set the bgcolor of a td tag is to change it's colour from the normal colour to an offset or highlighting colour of some sort...

Using GetRows to push the information in your recordset into an array is a fantastic way of dealing with data that comes from a database - however it can get complicated VERY quickly because unless your SQL statement is only pulling one column, you're going to return a multi-dimensional array and those can be hell. Using this method also helps speed up your asp pages immensely, it's very effective. However, for practical day to day use, it's better to just iterate through your recordset normally! I only use GetRows in very isolated scenarios. You may want to try GetString though. It's similar to GetRows in the sense that you can grab your data from your recordset, take it out, put it somewhere else, and then close your recordset up - except GetRows pushes the data into an Array, getString pushes the data into a String type variable - and you can tell it how to seperate the data in one line. For simple displaying of data where you don't care a WHOLE lot about the look and feel of the way the data is being spat out.. this is a fantastic way of going about it.

Here the syntax...

String = recordset.GetString(StringFormat, NumRows, ColumnDelimiter,
RowDelimiter, NullExpr)

An example...

strTable = rs.GetString(,,"</td><td>","</td></tr><tr><td>","&nbsp;")

This will seperate your data using td tags to seperate each column, and <tr> tags to seperate each row. Like you normally would most of the time anyway.

And a resource...

http://www.expertsforge.com/Web-Deve...utorial-38.asp

Anyway, that's besides the point. You're returning eof because of the following statement...

WHERE ShipDate = DateDiff(d, 0, GetDate()+1)

You're telling your database to return all columns within all records from the table called ShipSummary, but only if ShipDate is Equal to the difference in days between 0 and tomorrow - That doesn't make sense to SQL! What exactly is 0? And how exactly does one computer the difference in days between 0 and tomorrow?

So there are two problems with that.

DateDiff requires 2 valid dates to function properly. It will return a numerical value of (milliseconds, seconds, minutes, hours, etc whatever you specify) between the first date and the second date. Take these DateDiff statements as an example..

DateDiff(d,getDate(),getDate()+1) - this will return 1 because there is 1 days difference between today and tomorrow
DateDiff(d,10/10/2007,getDate()) - Since today's date (for me) is October the 18th 2007 - this statement will return 8 because there are 8 days between october the 10th and october the 18th.

The second problem with that statement is that you are telling SQL to return all records where the value of the column called ShipDate is equal to the value that DateDiff returns. If the column ShipDate contains and integer value, that's fine, but my guess is that it contains a DATE format like 10/10/2007 - in which case you are basically saying...

WHERE ShipDate = 1

Which will never be true, and thus no records will ever be returned, and your recordset will indefinitely return EOF.

Below is the proper way to compare the number of days between the value of a column in your database, and another date using DateDiff().

MySQL = "SELECT * FROM ShipSummary (NOLOCK) where Datediff(dd, ShipDate, GetDate()) = 1;"

Or if you want to return all records where ShipDate has a date within the last 7 days...

MySQL = "SELECT * FROM ShipSummary (NOLOCK) where Datediff(dd, ShipDate, GetDate()) <= 7;"

Hope that helps you out!
Sincerely,
Mark
Oct 18 '07 #5

jhardman
Expert 2.5K+
P: 3,405
cool, Mark, I'd never tried getString(). That looks really useful.

Jared
Oct 18 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.