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

Reading large Varchar value

Status
Not open for further replies.

MrJC

Programmer
Jan 3, 2002
27
GB
Hi all,

Was wondering if somebody could please help with the following problem that I'm having. I'm trying to read a field (type Varchar, length 8,000 chars) from a SQL Server database (using ADO 2.6 and the OLEDB provider for SQL Server).

Trouble is I'm just getting '(MEMO)' as the return value. I've attempted to use the getchunk method - this returns an error (the adfldlongtype property returns false). I've tried using CAST in my SQL statement to push the type over to NTEXT or NVARCHAR, basically a type that will work with the getchunk method - no joy.

I've even attempted to open the table without reference to SQL (adcmdtable) again same probs.

Has anybody had this problem before? Any help would be appreciated !

Many thanks,

Jon
 
Hi,

varchar field should just be read into a string (not using GetChunk which is inteded for 'text' and 'image' fields):

dim S as string
S = rst.fields("MyVarCharField").Value

If that does help - post you code.


Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
Yep must admit Sunaj, that's what I thought - whenever I use direct assignment I always get '(MEMO)' as the return datatype (I have checked the actual data in the field). Even when assigned to a string - variant, still '(MEMO)'.

Code wise, I'm using the following :

RecordSetObject.Open "SQL fragment here"

then :

TmpStore = RecordsetObject.Fields("ProbField")

Must admit, I'm including the primary key in the SQL fragment and ensuring that the large varchar field is always defined last.

Still no joy - if I was using ODBC, I'd start to suspect that the return field would have some sorta maximum value, OLEDB doesn't have any such restriction (do stand to be corrected) - I think :)

Jon
 
MrJC I just tested on my own sql server, and I don't have any problems retrieving varchar fields of up to 8000 characters.
I know that these are obvious things, but just checking:
Are you 100 % sure that the field is 'varchar' and not 'text'? Check that you are running on the correct data base (connection string)?
Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top