Problem about select uniqueidentifer field from SQL by using

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
huangchenmin
Posts: 157
Joined: Mon Jun 07, 2010 2:24 am

Problem about select uniqueidentifer field from SQL by using

Post 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
Attachments
SQLerror.JPG
SQLerror.JPG (137.33 KiB) Viewed 3581 times
User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Problem about select uniqueidentifer field from SQL by u

Post 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+"'"+';'
huangchenmin
Posts: 157
Joined: Mon Jun 07, 2010 2:24 am

Re: Problem about select uniqueidentifer field from SQL by u

Post 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
huangchenmin
Posts: 157
Joined: Mon Jun 07, 2010 2:24 am

Re: Problem about select uniqueidentifer field from SQL by u

Post 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
User avatar
Rathinagiri
Posts: 5482
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Problem about select uniqueidentifer field from SQL by u

Post by Rathinagiri »

Fantastic. Thanks a lot for sharing. :)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
Post Reply