Solved

MySQL / ASP - Invalid use of Null

Posted on 2009-07-08
8
766 Views
Last Modified: 2012-06-21
I am getting an "invalid use of null" error with the following code.

cottage_array = split((enquiries.Fields.Item("enquirycottage").Value),",")

There is definitely a value in the column.

If I do this instead I don't get the error:

dim str_enq : str_enq = (enquiries.Fields.Item("enquirycottage").Value)
cottage_array = split(str_enq,",")

I am using MySQL 5.1.

Any ideas..?
0
Comment
Question by:Orroland
  • 4
  • 3
8 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24808930
you have to first check if the field value is null or not.

this might work as shortcut:
cottage_array = split(("" & enquiries.Fields.Item("enquirycottage").Value),",")

Open in new window

0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24808933
otherwise:
dim v
v = ""
if not isnull(enquiries.Fields.Item("enquirycottage").Value) then
  v = enquiries.Fields.Item("enquirycottage").Value
end if
cottage_array = split(v,",")

Open in new window

0
 

Author Comment

by:Orroland
ID: 24808971
Thanks for the amazingly fast response.

Yes, I see that this workaround will fix the problem.  However, I don't understand why it is happening.  The field is a MySQL text field and DEFINITELY has a value.

If have just found that even if I do a response.write of the field value before the split() it works.  It seems that I need to extract the field value before it will work.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24808986
text field, you say? which size?
via odbc driver? which version?

that could be the problem... with the newest mysql odbc driver, or better the oledb provider, it should work better.
0
 

Author Comment

by:Orroland
ID: 24809095
My connection string:

driver={MySQL ODBC 5.1 Driver};server=xxx;uid=xxx; pwd=xxx;database=xxx;option=3;

How do I use the OLEDB provider?
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 24809117
0
 

Author Comment

by:Orroland
ID: 24809251
OK, I have downloaded, installed and activated their Provider.

I now just get a (very unhelpful) error when I try to open a recordset:

800410ff

My new connection string is:

Provider=MySQL Provider; Data Source=xxx; User ID =xxx; Password=xxx; Initial Catalog=xxx;

Does this look OK?
0
 
LVL 9

Expert Comment

by:rg20
ID: 24809619
I seem to recall an error with Oracle readers that once you read the value, you cant read it again, hence a null.

you might store it to a local variable then split it.  hence you dont' get the error
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ASP/VB email question 4 46
MySQL Backup Strategy 15 44
Call a function within the ASP code 4 19
Time comparison asp 1 10
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question