views:

1552

answers:

2

Hello everyone,

My question is how to assign the DataType value for columns of special SQL Types like, uniqueidentifier/nvarchar/datetime/varbinary(max) -- I did not find a mapping between .Net data type and such 4 types of SQL column data type?

Here is a sample, which shows we need to assign the DataType (this sample maps .Net type to SQL column data type) of each column of the DataTable.

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

thanks in advance, George

+4  A: 

Assuming you are talking about the DataType property on the DataColumn class, this is how you would map the types:

  • uniqueidentifier - Guid
  • nvarchar - String
  • datetime - DateTime
  • varbinary(max) - byte[]

You can find the full list of mappings here:

http://msdn.microsoft.com/en-us/library/ms131092.aspx

casperOne
Cool, casperOne! Are there any full mapping tables for any related .Net type for SQL Data type?
George2
Are there any full mapping tables for any related .Net type for SQL Data type?
George2
@George2 - This is what you want: http://msdn.microsoft.com/en-us/library/ms131092.aspx
casperOne
Excellent, casperOne! Just what I need! MSDN search engine and Google search engine does not give me what you showed, cool!!
George2
+1  A: 

You might also want to read this msdn page:
http://msdn.microsoft.com/en-us/library/system.data.datacolumn.datatype.aspx

Joel Coehoorn
But there is no mapping, just mentioned supported .Net data types for DataType property on the DataColumn class. Are there any documents covering a full mapping table for any related .Net type for SQL Data type?
George2
Are there any full mapping tables for any related .Net type for SQL Data type?
George2