473,473 Members | 2,282 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Microsoft VBScript compilation error '800a0400'

6 New Member
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
5 2836
JamieHowarth0
533 Recognized Expert Contributor
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
char
6 New Member
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
3,406 Recognized Expert Specialist
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
346 Recognized Expert Contributor
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
3,406 Recognized Expert Specialist
cool, Mark, I'd never tried getString(). That looks really useful.

Jared
Oct 18 '07 #6

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

Similar topics

3
by: Matt | last post by:
When the ASP statement end with a _ character, then the next line cannot have comment ' character. Is that correct? Since I encountered the following error: Microsoft VBScript compilation...
3
by: Adam Short | last post by:
Can anyone help? I have all of a sudden started to receive this error on my site! I have no idea what script it is executing, why it is now failing, what is going on?? All I have been able...
6
by: Adam Short | last post by:
Can anyone help? I have all of a sudden started to receive this error on my site! I have no idea what script it is executing, why it is now failing, what is going on?? All I have been able...
1
by: aklsdjfh | last post by:
I'm no expert in asp and vbscript but not a total beginner. I've got some VBScript in an asp page which is generating a forumla for use in Lotus Notes replication. The line that it is objecting...
2
by: JNariss | last post by:
I keep getting the following error message when trying to preview my page: Microsoft VBScript compilation error '800a0400' Expected statement /TESTESC.asp, line 33
2
by: sonasiva | last post by:
{asp code} Error Type: Microsoft VBScript compilation (0x800A03EE) Expected ')' /web/company_ind.asp, line 35, column 37 Response.Write(objrs("investor_name")""<a...
11
by: remya1000 | last post by:
While running the program, i'm getting this error Microsoft VBScript compilation error '800a0401' Expected end of statement /admin/currentmonth.asp, line 26 strSQL = "SELECT...
3
by: Indy | last post by:
Hi, I am new to VB and have some previous programming experiences. Curently working as an IT support person and trying to write a VB 6 script to access apos database and get one of the table's...
2
by: kevinr | last post by:
Hi, I am brand new to VB, and I am trying to deploy Office 2007 on my network here at work. We used part of this script to do another deployment, and I have taken pieces and tried to edit for this...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.