Page 1 of 1

Problem about select uniqueidentifer field from SQL by using

Posted: Thu May 24, 2012 9:36 am
by huangchenmin
Dear all:
I have using DBUSEAREA() for query data from SQL server 2008 and work well.
Today I encounter a big problem while query data from fields which is uniqueidentifier data type.
The DOS error message display while I execute application, which as attachment.
Following are partial source code:
227:m_sqlLogin:='select t_Pk from RACSystem..RACPatientInfo where t_PatientNo='+"'"+m_s1+"'"+';'
228:DBUSEAREA(.T.,,m_SQLLogin, "TEMPDBF1" )

The field 『t_Pk』is uniqueidentifier data type.
Please Help!
Best Regards
chen min

Re: Problem about select uniqueidentifer field from SQL by u

Posted: Thu May 24, 2012 12:15 pm
by mol
huangchenmin wrote:Dear all:
I have using DBUSEAREA() for query data from SQL server 2008 and work well.
Today I encounter a big problem while query data from fields which is uniqueidentifier data type.
The DOS error message display while I execute application, which as attachment.
Following are partial source code:
227:m_sqlLogin:='select t_Pk from RACSystem..RACPatientInfo where t_PatientNo='+"'"+m_s1+"'"+';'
228:DBUSEAREA(.T.,,m_SQLLogin, "TEMPDBF1" )

The field 『t_Pk』is uniqueidentifier data type.
Please Help!
Best Regards
chen min
Maybe these two dots are redundant? Maybe only one is required:

Code: Select all

227:m_sqlLogin:='select t_Pk from RACSystem.RACPatientInfo where t_PatientNo='+"'"+m_s1+"'"+';'

Re: Problem about select uniqueidentifer field from SQL by u

Posted: Fri May 25, 2012 1:28 am
by huangchenmin
mol wrote:
huangchenmin wrote:Dear all:
Maybe these two dots are redundant? Maybe only one is required:

Code: Select all

227:m_sqlLogin:='select t_Pk from RACSystem.RACPatientInfo where t_PatientNo='+"'"+m_s1+"'"+';'
Dear mol:
Thanks for replying to me.
I have been try before about 1 dot. It have to be 2 dot.
DBF take SQL uniqueidentifier as hexadecimal type and fail to deal with it.
I also tried to add SQL function 'CAST' or 'CONVERT' to m_SQLLOGIN. It also fails.
Best Regards
chen min

Re: Problem about select uniqueidentifer field from SQL by u

Posted: Sat May 26, 2012 9:09 am
by huangchenmin
mol wrote:
huangchenmin wrote:Dear all:
Maybe these two dots are redundant? Maybe only one is required:

Code: Select all

227:m_sqlLogin:='select t_Pk from RACSystem.RACPatientInfo where t_PatientNo='+"'"+m_s1+"'"+';'
Dear mol:
My problem had been solved!
You wouldn't believe how simple it is.
m_sqlLogin:='select CAST(t_Pk AS varchar(36)) AS DDAA from RACSystem..RACPatientInfo where t_PatientNo='+"'"+m_s1+"'"+';'

CAST(t_Pk AS varchar(36)) convert uniqueidentifier to varchar with length of 36 byte.
『AS』followed function CAST must have. It refer to a new title for query result that DBF could recognize.
Best Regards
chen min

Re: Problem about select uniqueidentifer field from SQL by u

Posted: Sat May 26, 2012 10:35 am
by mol
thanks for sharing!

Re: Problem about select uniqueidentifer field from SQL by u

Posted: Sat May 26, 2012 6:21 pm
by Rathinagiri
Fantastic. Thanks a lot for sharing. :)