Convert Type to SqlDataType and SqlDataType to Type C#
Type conversion basically involve casting and convert from one type to another. You can try the Type conversion by following this web site . Today i want to share code to convert from Type to SqlDataType. This method can be used for example to add parameters to SqlCommand based on DataTable column DataType, see example below : SqlCommand dbComm = new SqlCommand("<sql statement>",<sql connection>); dbComm.Parameters.Add("<parameter name>", < sql Data Type>]).Value = "test"; what about if you have DataTable and you want to automatically loop into column of datatable and and automatically assign Sql Data Type based on Column DataType of data table ..?There is nothing method or casting that available to do this, but after i googling about converting / casting DataType to SqlDataType, the result seem like impossible to done in .net . C# Parse SqlDbType Convertion C# data types to SQL Server data types Convert DataColumn.DataType to Sq...