473,698 Members | 2,603 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Add a new DataTable column with type "Integer"?

36 New Member
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,2 2 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 24468
Infog
36 New Member
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
1576
by: Igor Shevchenko | last post by:
Hi, Are there any plans on adding CLUSTER-related information to "\d tablename" ? -- Best regards, Igor Shevchenko ---------------------------(end of broadcast)--------------------------- TIP 8: explain analyze is your friend
4
2743
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) SelectionHighlightBackColour(BgColour) Dim rtb As New RichTextBox rtb.ForeColor = FgColour ===> error occured in fgcolour End Sub regards,
2
1252
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) Dim bColor, fColor, fgcolor, bgcolor As Integer .. .. .. fColor=Colour(fgcolor) ===> error occured in fgcolour .. ..
6
2130
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 why the "W" version would not work correctly? One reason is that the ByRef or ByVal does not show by InteliSence so the "p" would help there. ------ Secondly, I'd like to be consistent with the parameter names. I'd like to
11
3447
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 (e.g. location, contract, date modified, etc). Other than modified date, all my filters are selected via combo boxes. I would like to have the combo boxes update so that if there are no items available in the currently filtered list for a given selection, that selection will not appear in the...
2
720
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 seconds), compute aggregate functions on the columns, and ultimately feed the result into a graph-drawing web thingy. I'm trying a few different ways to get what seems to be the same data, and seeing some odd behavior from the query planner. The table looks like this:
12
4777
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 www.postgres.com and I found "serial" . But I don't know how to create auto_increment. here is my try:
6
12481
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 to change column "machineID" type from integer to varchar. I am looking for something like: alter table test alter column machineID ... ... varchar
9
2862
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 echo "63918000009" > k cat k read x < k (( aj=63918000009 )) if
0
8680
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8609
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9030
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7738
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.