Link to home
Start Free TrialLog in
Avatar of SpikeDog
SpikeDog

asked on

Can't get more than 255 chars from Access DB

Is there a way to get more than 255 chars from an Access DB in asp?
When I had the field as memo it returned nothing. I changed it to text(255) and that works but I need a LOT more than that.
Do I have to go to SQL Server, and if so, what field type?

Thanks
Avatar of pramesh
pramesh

Yes Use GetChunk method to retrieve data from a memo field.
Post your code, I get severasl Memo fields to work in an Access DB without having to use the GetChunk.
Avatar of SpikeDog

ASKER

I open my recordset through ADO and a DSN.
Then I say :
profiletext = rs("profiletext")

ProfileText seems to be empty even though there are hundreds of chars in the field.
SpikeDog,  I regularly read and write memo fields from my Access tables to ASP and haven't  encountered the problem you are describing....

why don't you try a simple asp page that reads only the memo field in the ADO recordset and display them....  use the response object to check that the data is there...

It depends on the cursor type you are using. What does your open and recordset commands look like? Can you post them here?
What version of the software (i.e. IIS, ODBC and etc) you are using on the server?
I did encounter this problem before but I found out that it's caused by the older software version.
I work with databases all the time, and especially with memo fields. MDB-database files shouldn't be hard at all with memo fields (unlike SQL-server).
Here goes

1) are you sure you are SELECTing the memo field from the database.

2) try another statement which only select the memo field, and write it out

SQL = "select memofield from table"
set rs = Connection.Execute(SQL)
response.write rs("memofield")

3) try to be case sensitive, maybe that's what is going wrong (shoul;dn't be it though).

4) when using a memo field, and looking at the page, and when you see no error message or whatsoever. Just use the "view source" button....look through the code and see if there is somewhere an error message.

Good luck,
CJ
btw

GetChunck isn't necessary at all.
Thanks for all the comments.
I now know why it wasn't working.
However, it has raised a bigger issue and I'm offering my entire collection of 85 points to anyone that can tell me why - because I'd like to know.
Here's the answer:
To ensure that the value I get back from the rs is not a null I do a fairly obvious thing. I say
if isnull(rs("whatever")) then
    strwhatever = ""
else
    strwhatever = rs("whatever")
end if

This should work right?
It always has before.
I tested this under VB so I could watch the vars and I found that as soon as I exeuted the 'if isnull' line the value of rs("whatever") went from my load of chars to null. I watched it change via the intellisense popup.
Why would testing the value make it equal to null?
I got around this by saying:
strwhatever = rs("whatever") & ""
which is what I usually do when I remember.
Any ideas?
First person to explain the null thingy gets my points and my undying gratitude.

Client uses ADO 2.1, server is win2k unpatched.
Adjusted points from 30 to 85
Just one thing about SQL.

With SQL you always have to select the memo-field(s) after the other (normal) fields.....also, when trying to show them you cannot show them directly (well, you can, but you can't re-use them), you always have to put them into a variable first, and then use 'em.
This is also what i was implying when I said "unlike SQL".

Seems the same was happening with you.
Try to check what is the version of MDAC. It should be MDAC ver 2.0. If it is earlier version then u can not retrieve more than 255 char. Try to install the MDAC ver 2.0 and check it out. It should work.
sasidhargn, this is definitely not the issue. As I mentioned in my last comment the whole thing works OK when I don't check for a null first. Answer that and you can have the points.
SpikeDog, Sorry i may misunderstand about ur question. Once i faced the same problem using ASP, that i can not get more than 255 char. that time problem is with MDAC. U can try another also. while querying itself check for null and trim it.u can write the query like below.

select trim(isnull(field,"")) from table

Some times in memo fields if u dont trim also it created problems. Just try it. If i misunderstood the question then its ok..leave it....
No worries sasi
It is definitely a weird thing.
I just can't test for a null value without the value becoming null.
ASKER CERTIFIED SOLUTION
Avatar of mouatts
mouatts

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Good enough for me ...