Marc Vanzegbroeck wrote:Hi,
I'm converting my program from tMySQL to ADO and have still some convertion-problems.
I tMySQL I had oQry:fieldname() , oQry:fieldtype() , oQry:fieldlen() and oQry:fielddec() to get the structure of the table.
I found that I can use oRs:fields(1):name to get the name, but how can I get the type, len en dec?
Thanks,
Marc
oRs:Fields( 1 ):Type
oRs:Fields( 1 ):DefinedSize //for character types
oRs:Fields( 1 ):Precision //for numeric types
oRs:Fields( 1 ):NumericScale //for numeric types
Marc Vanzegbroeck wrote:Thanks Enrico,
For a type CHAR in the database oRs:Fields( 1 ):Type returns 129. Where can I find what number is what type?
Marc Vanzegbroeck wrote:Do you know also how I know the number of fields in the table?
I tested it with len(oRs:Fields()), but the result is always 4
oRs:Fields:Count()
Marc Vanzegbroeck wrote:oRs:Fields( 1 ):DefinedSize is giving me the correct sise of a CHAR-field, but for numeric fields Precision gives not a correct value and NumericScale is always 255.
Marc Vanzegbroeck wrote:I think it's not possible to get the correct size via ADO for numeric fields.
Enrico Maria Giordano wrote:Works fine for me. Please note that you have to define the field as NUMERIC.
Marc Vanzegbroeck wrote:Sorry, I tested it on a fieldtype 'Double' and 'SmallInt'.
Marc Vanzegbroeck wrote:According to http://www.w3schools.com/ado/ado_datatypes.asp, numerics are only available on Access 2000 (OLEDB) , type 131.
Enrico Maria Giordano wrote:You can't get the size of that types because they have fixed sizes.
Marc Vanzegbroeck wrote:If I check the SQL-database with a program like HeidiSQL, I see that de size is not fixed, but just like I defined when I created them with tMySQL. I have type double, with Length 10 , Set 3 or Lengte 4, Set 1,...
Also the smallint have different sizes.
Marc Vanzegbroeck wrote:Enrico,
As you can see here, I have double of 4,1 and 15,5 and SMALLINT of 2 and 1.
Marc Vanzegbroeck wrote:Enrico,
I have change my type from double to decimal, and now Precision and NumericScale are working fine!!!
Thanks
IF nType >= 256
nType := nType - 256
lNulls := .f.
ELSE
nType := nType
lNulls := .t.
ENDIF
IF nType = 5
nDec := nLength - (INT(nLen/256)*256)
nLen := INT(nLength/256)
ENDIF
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 89 guests