-
June 5th, 2009, 03:43 AM
#1
Recordset GetFieldValue for list values
Hello All,
this is my first post here, but I tried several things before posting here...
Here is my problem :
I'm reading different tables inside an Access Database (I'm more used to SQL...), and for some specific fields, i'm getting strange readings...
here is the code :
"CString csRequete;
CDaoRecordset recordset2(&database);
COleVariant l_vProcedure;
csRequete.Format("SELECT * FROM [LB Analysis Profiles] WHERE [LB Analysis Profile Key] = %d",l_vAnalysisProfile.intVal);
recordset2.Open(AFX_DAO_USE_DEFAULT_TYPE,csRequete.GetBuffer(), 0);
recordset2.MoveFirst();
l_vProcedure = recordset2.GetFieldValue(17);
csProcedure = l_vProcedure.bstrVal;"
The problem is that I am getting Chinese symbols in the BSTR of l_vProcedure, or invalid characters...
the field is a text type containing "FILTRE", and that's what I should read...
This functions are working fine on others tables, or for some numerical value...
Do you have any idea what can be happening?
Thanks on advance
-
June 5th, 2009, 03:45 AM
#2
Re: Recordset GetFieldValue for list values
I'd like to add one thing :
the content of the requiered field is a text coming from a query, so it's a combobox selected text.
-
June 5th, 2009, 10:21 AM
#3
Re: Recordset GetFieldValue for list values
Ok, I finally found what happened...
Contrarely to what the variant said, it's not a BSTR type, the data to read is :
"csProcedure = l_vProcedure.pbVal;"
I don't know why it's so, but it can be useful to someone any day ^^
good luck.
-
June 5th, 2009, 04:02 PM
#4
Re: Recordset GetFieldValue for list values
Hmm, I use DAO and a somewhat simular technique/approach that works well. I don't have time to look it up right now, but I don't use .GetBuffer().
Why are you using .GetBuffer()? ... if I recall correctly you just enter the value CString.
.. I think you are also using Bstr value incorrectly.
-
June 8th, 2009, 02:49 AM
#5
Re: Recordset GetFieldValue for list values
Hi CNemo, thanks for your answer.
I'm using .GetBuffer() because I had several problems retrieving text from CString in the past.
This is a habit I have which prevent me from having some conversion problems.
I agree it may not be necessary here.
The use of BSTR may be wrong... but the solution here is :
"l_vProcedure = recordset2.GetFieldValue(17);
csProcedure = l_vProcedure.pbVal;"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|