Forums

This topic is locked

Microsoft VBScript runtime (0x800A005E)

Posted 09 Aug 2005 16:14:03
1
has voted
09 Aug 2005 16:14:03 Mashkur Alam posted:
Hi,

On my insert form I am getting a error:

Error Type:
Microsoft VBScript runtime (0x800A005E)
Invalid use of Null: 'CStr'


Which contains:

<select name="Parking">
<option value="" >Please Select One</option>
<option value="Yes" <%If (CStr((rsSales.Fields.Item("Parking".Value)) = CStr("Yes") Then Response.Write("SELECTED" : Response.Write(""%>>Yes</option>
<option value="No" <%If (CStr((rsSales.Fields.Item("Parking".Value)) = CStr("No") Then Response.Write("SELECTED" : Response.Write(""%>>No</option>
<option value="Off Street" <%If (CStr((rsSales.Fields.Item("Parking".Value)) = CStr("Off Street") Then Response.Write("SELECTED" : Response.Write(""%>>Off Street</option>
<option value="Not Specified" <%If (CStr((rsSales.Fields.Item("Parking".Value)) = CStr("Not Specified") Then Response.Write("SELECTED" : Response.Write(""%>>Not Specified</option>
</select>

Please anyone help with advice, why this NULL value error coming.

Regards

Babu

Replies

Replied 10 Aug 2005 19:33:03
10 Aug 2005 19:33:03 myke black replied:
ah the old 0x800A005E error - this is a non specific database error and does not actually tell you anything useful other than your code is not working. Dontcha just love MS error messages?

anyway....

the CStr method 'casts' a data type to a string (ie tries to convert the target data into a string type). In databases, empty fields can be either a zero length string, or a NULL value - which is kinda like the difference between a box containing nothing, and a box containing a vacuum, if you see what i mean? They are both empty, but when you try to put your head in the one with the vacuum, your brains sloop outta your ears....

anyway metaphores aside, what you need to do is check the the record is not a null value first, because you cant convert a null value into a string, number, date or any other data type. You need to change your code to something like this:



<%
parking = rsSales.Fields.Item("Parking".Value
if not isNull(parking) then
parking = cstr(Parking)
end if
%>
<select name="Parking">
<option value="">Please Select One</option>
<option value="Yes" <% If parking = "Yes" Then Response.Write("SELECTED" %>>Yes</option>
<option value="No" <% If parking = "No" Then Response.Write("SELECTED" %>>No</option>
<option value="Off Street" <% If parking = "Off Street" Then Response.Write("SELECTED" %>>Off Street</option>
<option value="Not Specified"<% If parking = "Not Specified" Then Response.Write("SELECTED" %>>Not Specified</option>
</select>




Reply to this topic