none
Odbc GetSchemaTable DataType Isn't DbType RRS feed

Answers

  • I kind of expected that the types would be the .NET types but the doc (http://msdn.microsoft.com/en-us/library/system.data.odbc.odbcdatareader.getschematable.aspx ) says that DataType "Maps to the common language runtime type of DbType ."  I just don't want to find that I coded for a system type and an update to the framework comes along later that matches the doc and suddenly my code doesn't work.


    That would seem to imply that Microsoft would change the underlying mapping between .NET database data types and ODBC data types. I don't see that as being very likely, especially since it would involve a major impact on existing code.

    Reading the doc though, it appears that "mapping" to DbType does not mean that the value returned is from the DbType enum.

     


    Paul ~~~~ Microsoft MVP (Visual Basic)
    • Marked as answer by Jason Roe Friday, September 24, 2010 4:32 PM
    Friday, September 24, 2010 1:47 PM

All replies

  • I move this thread to ADO.NET forum for better support.
    Sincerely,
    Eric
    MSDN Subscriber Support in Forum
    If you have any feedback of our support, please contact msdnmg@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, September 13, 2010 3:17 AM
  • Hi quizout,

    What system type did you get when you run the query and what DbType did you expect to get ? Could you please provide us a sample project to reproduce the problem ? Thanks.

    Best regards,
    Alex Liang
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, September 13, 2010 7:09 AM
    Moderator
  • I'm not exactly sure what the question is. The ADO.NET objects are database independent so naturally they would implement the system data types. The below link contains data type mapping between the .NET data types and the database provider data types.

    http://msdn.microsoft.com/en-us/library/4e5xt97a%28VS.80%29.aspx

     


    Paul ~~~~ Microsoft MVP (Visual Basic)
    Monday, September 13, 2010 1:52 PM
  • Hi quizout,

    "When a DataAdapter fills a DataTable in a DataSet with values from a data source, the resulting data types of the columns in the DataTable are .NET Framework types, rather than types specific to the .NET Framework data provider used to connect to the data source.

    Likewise, when a DataReader returns a value from a data source, the resulting value is stored in a local variable that has a .NET Framework type.”

    If you check the Data type of the DataType column of the table returned by GetSchemaTable, you will find that the DataType column’s data type is System.Type.


    Best regards,

    Alex Liang

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Tuesday, September 14, 2010 2:17 AM
    Moderator
  • I kind of expected that the types would be the .NET types but the doc (http://msdn.microsoft.com/en-us/library/system.data.odbc.odbcdatareader.getschematable.aspx) says that DataType "Maps to the common language runtime type of DbType."  I just don't want to find that I coded for a system type and an update to the framework comes along later that matches the doc and suddenly my code doesn't work.
    Friday, September 24, 2010 3:11 AM
  • Hi quizout,


    Could you please clarify what do you mean by "I just don't want to find that I coded for a system type and an update to the framework comes along later that matches the doc...", and could you please post the code that doesn't work ? Thanks.

    Best regards,

    Alex Liang

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Friday, September 24, 2010 3:37 AM
    Moderator
  • I kind of expected that the types would be the .NET types but the doc (http://msdn.microsoft.com/en-us/library/system.data.odbc.odbcdatareader.getschematable.aspx ) says that DataType "Maps to the common language runtime type of DbType ."  I just don't want to find that I coded for a system type and an update to the framework comes along later that matches the doc and suddenly my code doesn't work.


    That would seem to imply that Microsoft would change the underlying mapping between .NET database data types and ODBC data types. I don't see that as being very likely, especially since it would involve a major impact on existing code.

    Reading the doc though, it appears that "mapping" to DbType does not mean that the value returned is from the DbType enum.

     


    Paul ~~~~ Microsoft MVP (Visual Basic)
    • Marked as answer by Jason Roe Friday, September 24, 2010 4:32 PM
    Friday, September 24, 2010 1:47 PM
  • Actually, documentation in .NET 4.5 doesn't mention DataType property at all, although documentation for .NET 4.0 does mention this property. There is DataTypeName property that seems to correspond to SQL Server type. Also, you can use ProviderType property that can be cast to SqlDbType (found this info in some blog post).

    For every expert, there is an equal and opposite expert. - Becker's Law


    My blog


    My TechNet articles

    Tuesday, July 30, 2013 11:25 PM
  • I don't have access to VS 2012 at the moment but I would suspect that there is an error in the documentation. There is nothing in the documentation to indicate that the DataType property has been deprecated in .NET Framework version 4.5.

    Paul ~~~~ Microsoft MVP (Visual Basic)

    Wednesday, July 31, 2013 12:47 PM
  • Yes, I am thinking this as well. How should we notify people who are responsible for documentation about this problem?

    For every expert, there is an equal and opposite expert. - Becker's Law


    My blog


    My TechNet articles

    Wednesday, July 31, 2013 2:40 PM