SQL Server to .Net type conversions

后端 未结 3 1289
無奈伤痛
無奈伤痛 2021-01-03 02:34

I have the following map that I use to convert betwen SQL Server types, SQLData types, and .NET types:

/// 
    /// The map of types. THis map         


        
相关标签:
3条回答
  • 2021-01-03 03:08

    char is not the correct .NET data type for a SQL Server char. It must be converted to either char[] or string, since a SQL char can hold more than one character.

    The Microsoft reference here agrees with me. The other ones look correct.

    0 讨论(0)
  • 2021-01-03 03:19

    According to MSDN you have all three (char, varchar, text) correct.

    See: http://msdn.microsoft.com/en-us/library/system.data.sqltypes.aspx

    0 讨论(0)
  • 2021-01-03 03:23

    Also to add one more for SQL 2008 anyway Table converts to DataTable

    I give an example of how to use this type here SQL Server stored procedure convert varchar to int

    [Edit]

            char is not the correct .NET data type for a SQL Server char. 
        It must be converted to either char[] or string,
     since a SQL char can hold more than one character.
    

    Credit to @RedFilter for that one

    0 讨论(0)
提交回复
热议问题