How to ...

  • Thread starter Thread starter Jacek Jurkowski
  • Start date Start date
Hi Jacek,

Based on my understanding, you want to determine a certain datacolumn's
scale and precision in a table.

Do you get your data from Sql Server?

You may use SqlDataReader.GetSqlDecimal to get SqlDecimal object, then you
may get the scale and precision through SqlDecimal.Scale and
SqlDecimal.Precision properties.

============================
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Jeffrey I don't know the table source.
I just have some table and i would like to
determine column precision and scale
 
Hi Jacek,

Thanks for your feedback.

Where does your datatable come from? Is it from database?

I think you may use DataColumn.DataType property to determine the column
type first. Only Decimal type has scale and precision. If your columns'
data type is not decimal, then your request makes no sense.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Problem in general ...

I'tt tell You what I'm trying to do and why do I need to
determine the column's precision ... I'm writing an application
that MUST work on both: SqlServer and Visual Fox Pro as
an DataSource (maybe Oracle if will be needed). My client's
are Big (above 1000 peoples) as good as smal ones (les than <100)
Those secound ones doesn't commonly have any IT cell or any
support so any changes in DataBase structure has to be done from
my application. I must to connect to my DataSource , check it's
structure and do some changes if needed ... Columns in the data base
are created from text columns definition file with type conversions
shown in a table:

Types described in collumns definition file.Types like c# except text.
Columns are created in Sql server as follows: Columns are created in Vfp
server as follows:
If compatible with my older application. Without compatibility If
compatible with my older application. Bez zgodnosci






String
Char (x)*
Char (x)
Char (x)
Char (x)

Int
Decimal (x,0)*
Int
Numeric (x,0)
Int

Double
Decimal (x,y)
Decimal (x,y)
Numeric (x,y)
Numeric (x,y)

Bool
Decimal (1,0)
Decimal (1,0)
Numeric (1,0)
Decimal (1,0)

Text
Char (250)
Text
Char (250)
Memo


x,y - scale and precision

So to be sure that my DataSource is Ok i must to obtain
it's current structure (f.e. by sp_columns) and compare it with
my definition file ... The problem is that VFP equivalent of sp_table
(AFFIELDS()) is not working propelly (not supported?) by VFP
OLEDB provider... So I think I could compare definitions with
DataTable selected from DataSource including the diferences...

By the way ...

When Select command is executed in Database and Ado.net
fills DataTable columns in select are converted to only two types used
later in my application as follows:

Types described in collumns definition file.Types like c# except text.
Internal application c# type:
String
String

Int
Double

Double
Double

Bool
Double

Text
String



Sorry My English :-)
Feel free to correct mistakes in my plan ...
 
Hi Jacek,

Thanks very much for your feedback.

Based on you statement, I think you just want to determine your underlying
database's column scale and precision?

I think because of various databases, you should use ADOX to get what you
want. The column object of ADOX has Precision Property, please refer to:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/
adobjcolumn.asp

Also, there is a VB sample shows you how to get the NumericScale and
Precision properties of the Column object, please refer to:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/
admscnumericscaleprecisionpropertiesexamplex.asp

In .Net, you may use COM interop "Microsoft ADO Ext. 2.7 for DDL and
Security" to use ADOX, please refer to:
http://support.microsoft.com/?id=317881

=======================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi Jacek,

Does my reply makes sense to you? Do you still have any concern?

Please feel free to let me know, I will help you. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top