473,387 Members | 3,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

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.
Oct 8 '06 #1
3 12281
VVenk,

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

Cor

"vvenk" <vv***@discussions.microsoft.comschreef in bericht
news:97**********************************@microsof t.com...
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.

Oct 8 '06 #2
Cor:

So, how can find out what the data type is?

"Cor Ligthert [MVP]" wrote:
VVenk,

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

Cor

"vvenk" <vv***@discussions.microsoft.comschreef in bericht
news:97**********************************@microsof t.com...
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.


Oct 8 '06 #3
vvenk wrote:
So, how can find out what the data type is?
Use the dtTable.Columns(index).DataType property.

HTH,

--

(O)enone
Oct 8 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: serge | last post by:
My project is to automate testing of Stored Procedures of type SELECT (at least for now). I want to create a table where each stored procedure's input parameter values are entered and in another...
3
by: Leo | last post by:
Thanks for the Help in Advance!! I am a beginner in VB.Net. I am trying to create a form which is displayed in a email for our customers to fill in a Request for quote. I would like them to type...
9
by: Ben R. | last post by:
Hi guys, I've got a DB table of timecards with these fields in the table: ID (Int) UserID (Int) DateWorked (DateTime) HoursWorkedOnThatDate (Double) I'd like to display a grid, with...
5
by: rAinDeEr | last post by:
Hi, I have a web application with a table to store terms and conditions of a Company. This may some times run into many pages and some times it may be just a few sentences. It is a character...
0
by: Jacob Donajkowski | last post by:
Once the user logs in I want to have the users switch from the Roster View to the Profile View and enter their profile infomation and save it. Then the next time they login and go to the Profile...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.