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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I get Null, but the field is not empty! 1

Status
Not open for further replies.

Smarty

Programmer
Apr 12, 2001
191
BE
Hey,
With the following line of code, the result of the field("ENBODY") is Null, while I am sure that in my table this field is not empty at all:
dim bdy
bdy = rs.fields("ENBODY")
bdy = replace(bdy, Chr(10),&quot;<BR>&quot;)
bdy = replace(bdy,chr(17),&quot;'&quot;)
response.write bdy
when i try the exact same thing with another field(&quot;body_fr&quot;) everything works fine... what can be wrong here?

 
What do you get if you just put:

response.write(&quot;*&quot; & rs.fields(&quot;ENBODY&quot;) & &quot;*&quot;)

Anything between the stars?

Also try:

if isnull(rs.fields(&quot;ENBODY&quot;)) = true then
response.write(&quot;This field is NULL&quot;)
else
response.write(&quot;This field isn't NULL&quot;)
end if

If the field turns out to be null and you think it shouldn't be, post the code you use to define and set up your connection and recordset.
 
Well if i try that, there is nothing between the stars, and the field is NULL by the test. Here is some more code i use, but the strange thing is that i do exactly the same with another similar field body_fr and that works just fine

dim rs
Set Conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
Conn.Open &quot;DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=&quot; & Server.MapPath(&quot;..\Data\products.mdb&quot;)
dim ssql
SSql = &quot;Select * from promotions order by datum DESC, uur DESC&quot;
set rs = conn.Execute(sSQL)
...
if trim(rs.Fields(&quot;entitel&quot;)) = &quot;&quot; or trim(rs.Fields(&quot;enbody&quot;)) = &quot;&quot; then
...
else

response.write (&quot;<font face=Verdana, Arial, Helvetica, sans-serif size=2>&quot;)
dim bdy
bdy = rs.fields(&quot;ENBODY&quot;)
bdy = replace(bdy, Chr(10),&quot;<BR>&quot;)
bdy = replace(bdy,chr(17),&quot;'&quot;)
response.write bdy
response.write (&quot;</font><p align=right><i><a href=#top>Top</a></i></p><hr><br><hr><br>&quot;)



end if
 
You ought to define rs to be a recordset:

set rs = server.createobject(&quot;ADODB.recordset&quot;)

Also, try using explicit .value (rs.fields(&quot;<field>&quot;).value) rather than relying on the default property. In ASP.NET this will be mandatory anyway. May as well get used to it now!

Also, try this as a debugging technique to show you whats in the recordset:

response.write(&quot;<table>&quot;)
for a = 0 to rs.fields.count - 1
response.write(&quot;<tr>&quot;)
response.write(&quot;<td>&quot; & rs.fields(a).name & &quot;</td>&quot;)
response.write(&quot;<td>&quot; & rs.fields(a).type & &quot;</td>&quot;)
response.write(&quot;<td>&quot; & rs.fields(a).value & &quot;</td>&quot;)
response.write(&quot;</tr>&quot;)
next
response.write(&quot;</table>&quot;)

Is the field thats wrong the same data type as the field thats OK?
 
I added that recordset, but the field is still Null
.name = ENBODY
.type = 203

I don't get it... damned this is ****
but thanx for your efforts
 
Type 203 is:

adLongVarWChar - A long null-terminated Unicode string value

Is this the same as your other field, the one that works OK?

What is the data type of the in Access?

Try using an oledb connection string, something like:

conn.open(&quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\datbase\mydata.mdb;Persist Security Info=False&quot;)

You might need to get a later version of MDAC.
 
YOU ARE JUST GREAT!!!!

It worked with the oledb connection string... what was wrong is still a mistery to me but now it works!! thank you so much!!
 
You were using ODBC which can cause some weird stuff at times. Glad it now works! :-D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top