Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Empty recordset field creates an empty temporary string >:-(

Status
Not open for further replies.

ZuperDuper

Programmer
Jun 4, 2004
39
0
0
US
I am trying to open up a dbf table with adodb.recordset
and put value to a tempString.
tempString.Text = polrs.Fields("MYFIELD").Value.ToString
the only problem is that if MYFIELD is empty, tempString=""
I guess that the field value is trimmed automatically, which is not good. What if I need to check for a substring with a field, I might run into outbounds error.
I know that I can check for an empty string, etc., but that could be a problem too, since I might need to check for spaces, in which case I would need to fill the temp string with spaces.
Is there a way to directly get the field and if it empty, get the equivalent in empty space string?

You should never underestimate the predictability of stupidity.
 
You should check your field for spaces if that is causing the problem, and to check for certain positions you can use the Right,Left,Mid cammands to get those.. and if = spaces just move spaces to the field.
 
Yeah, I understand that I can check for an empty string, but that doesnt really help. Since then I would have to keep the field sizes for the record somewhere, and insert those spaces into the temp variable. This seems like a giant pain in the butt.

I was wondering if its possible to get the whole field even if its just spaces, I know VB6 allows that. Here is an example of the vb6 code that i have:

If Mid(rsttable!c, 209, 2) = " "
Then
'do stuff
End If

equivalent of this in VB.NET seems to be this:

if rsttable.fields("C").value.tostring.substring(208,2)=" "
then
'do stuff
endif

BUT it does not work. I know this might be a trivial problem for someone, but I am not an expert by all means, and I have researched on my own, without any result.


You should never underestimate the predictability of stupidity.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top