|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How can I get the data type of a data table's columns?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. VVenk,
System.DBNull tells that there is no value in the item, it is not the column. Cor Show quoteHide quote "vvenk" <vv***@discussions.microsoft.com> schreef in bericht news:975EB1E2-84EE-4680-817C-E974BDFD47A6@microsoft.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. Cor:
So, how can find out what the data type is? Show quoteHide quote "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.com> schreef in bericht > news:975EB1E2-84EE-4680-817C-E974BDFD47A6@microsoft.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. > > > vvenk wrote:
> So, how can find out what the data type is? Use the dtTable.Columns(index).DataType property.HTH, -- (O)enone
VB 6 developers and .Net
How to assign value to a dropdown box items? Experience Request: GPS Application How to prevent Pasting into textbox? What is the optimal way to upload 10,000 records to Oracle DB? Multi-dimensional array - Question on Data types How do I replace unwanted characters from a string using Reg Exp? efficient routine to parse a text string Memory problem with vb.net + webServices + DLL uncleared code |
|||||||||||||||||||||||