472,345 Members | 1,625 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Add a new DataTable column with type "Integer"?

36
I have a dataview, and I am trying to "clone" its structure only in part, by creating a new table via code. I cut out most of the columns, so this is easier to read. My question is - Why does this always seem to add things a a string?

Later in my code, I try to sort based on "View_Order", but it acts like a string. The values sort as 1,2,20,21,22,3,4, NOT 1,2,3,4,20,21,22 like it should.

Using Cint() while moving the values from table to table didn't work for me... and the boolean becomes text as well. Is the problem in this code, or would it be elsewhere?

Expand|Select|Wrap|Line Numbers
  1.     Private Function ConvertTable(ByVal ds As DataSet, ByVal TableName As String, Byval WHEREexpression As String, Byval  SORTexpression As String) As DataTable
  2.         'For Schedule Tasks, convert all "dates+times" to "dates only" as strings
  3.  
  4.         Dim dv As DataView = GetViewTable(ds.Tables(TableName), WHEREexppression, SORTexpression)
  5.         Dim dt As New DataTable
  6.  
  7.         dt.Columns.Add(New DataColumn("Task", GetType(String)))
  8.         dt.Columns.Add(New DataColumn("View_Order", System.Type.GetType("System.Int64")))
  9.         dt.Columns.Add(New DataColumn("Completed", GetType(Boolean)))
  10.  
  11.         For i = 0 To dv.Table.Rows.Count - 1
  12.             dt.Rows.Add()
  13.  
  14.             dt.Rows(i).Item("Task") = dv.Table.Rows(i).Item("Task").ToString
  15.  
  16.             dt.Rows(i).Item("View_Order") = CInt(dv.Table.Rows(i).Item("View_Order").ToString)
  17.             Try
  18.                 dt.Rows(i).Item("Completed") = dv.Table.Rows(i).Item("Completed")
  19.             Catch ex As Exception
  20.             End Try
  21.         Next i
  22.  
  23.         Return dt
  24.     End Function
  25.  
Feb 27 '09 #1
1 24027
Infog
36
Nevermind... I found the solution. The problem was that eveything had already been converted to strings before I ran the function.
Mar 2 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Igor Shevchenko | last post by:
Hi, Are there any plans on adding CLUSTER-related information to "\d tablename" ? -- Best regards, Igor Shevchenko ...
4
by: Supra | last post by:
value of type "Integer" cannot be convert to system.color Public Sub APIHighlight2(ByVal BgColour As Integer, ByVal FgColour As Integer)...
2
by: Supra | last post by:
value of type "Integer" cannot be convert to system.color. in procedure events: Function doColor(ByVal rtb As RichTextBox, ByVal a As String)...
6
by: **Developer** | last post by:
Notice below I sometimes used the "A" version. I found by cut-and-try that only the "A" version would work correctly. Anyone have a suggestion of...
11
by: Ron L | last post by:
I have a data table that lists a series of items in my database. In my user form, I want the user to be able to filter by a number of criteria...
2
by: Zygo Blaxell | last post by:
I have a table with a few million rows of temperature data keyed by timestamp. I want to group these rows by timestamp intervals (e.g. every 32...
12
by: Prabu Subroto | last post by:
Dear my friends... I am using postgres 7.4 and SuSE 9.1. I want to use auto_increment as on MySQL. I look up the documentation on...
6
by: Ying Lu | last post by:
Hi, I have a question about alter a column's type in a postgreSQL table. For example, I have 10, 000 records in a table name "test", I'd like...
9
by: coaxfiber | last post by:
why is it that when i used the value with zero,comparing two integers,it seems that i got the wrong ouput? Please consider the ff: #!/bin/ksh...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...

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.