How can I get the data type of a data table's columns?

G

Guest

Hello:

I created a datatable with two columns:

' Add three column objects to the table.
idColumn = New DataColumn()
idColumn.DataType = System.Type.GetType("System.String")
idColumn.ColumnName = "CaseId"
dtTable.Columns.Add(idColumn)

idColumn = New DataColumn()
idColumn.DataType = System.Type.GetType("System.Int64")
idColumn.ColumnName = "CaseVersion"
dtTable.Columns.Add(idColumn)

During run-time, I want to get the data type of each column so that I can
cast the data to the right datatype.

But when I investigate using Row(ColumnIndex).GetType.FullName, I alway get
"System.DBNull" irregardless of what column it is.

Can somebody guide me?

Thanks.

Venki

ps: I initially postedt this message under a different discusson group by
mistake. I apologize for double-posting.
 
C

Cor Ligthert [MVP]

VVenk,

System.DBNull tells that there is no value in the item, it is not the
column.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top