VB6 ADO recordset object has only null values for all rows returned for a given column, but the same query returns data(?)


I have a recordset with rows that I am pulling into a VB6 app from SQL Server 2000 via ADO, and one of the fields is giving me only nulls.

r.Fields("Name").Value  is how I am accessing it.  In sql server it is of type varchar, and it is intended to be a field that can hold numbers and strings (which is why I made it varchar).  

Is there anything I need to know about this datatype, or the way I am accessing it, which would prevent these nulls?

Other columns from the same query are returning values in my vb app, and the same exact query in SQL Server query analyzer is returning data for the column "Name"...

Thanks in advance!
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.

I would declare it as string and convert it as needed - what are the criteria between it being string and numeric?
Anthony PerkinsCommented:
If the fact that it is Null is causing you grief than add an empty space to it, as in:
YourValue = r.Fields("Name").Value & ''
Or try explicitly converting to a string...

.. Alan
hmmm  " the same exact query in SQL Server query analyzer is returning data for the column "Name"..."

That just shouldn't happen.  varchar is pretty simple and doesn't need the special handling described above if the query indeed returns values for that column.  Are you sure you used the EXACT same query on the SAME database?  Did you cut and paste?  Can you post your SQL?

That notwithstanding, some things that can cause unexpected nulls are outer joins that are fouled up, concatenation with a null (e.g. Fname + LName will return null if either field is null).

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
gurteenAuthor Commented:
Thanks for your help.  It did turn out to be a join that I made a mistake on, so I must repent.

It works now.  Sorry for the confusion...
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
Visual Basic Classic

From novice to tech pro — start learning today.