473,378 Members | 1,426 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,378 software developers and data experts.

Dataset read as integer?

Jon
i have a dataset with a few datatable inside.
most of my table are have values as in integer or double.

but everything i read my table out
e.g. "row.Item("ItemName").ToString

I always need to use the "ToString" method to read the entry out, which means
i need to convert it with Integer.Parse().....then store it to another
integer...then do calculation...then store it back to the datatable using the
ToString method again.
Theres just too many convertion!!

I am thinking is that a way to read out the value in datatable as a integer
straight away?

I tried using ".value", but it seems doesn't work, i cannot load it into an
integer or Double.

any ideas please! thankyou.
Nov 21 '05 #1
4 5358
Jon,

The Items are object and should be with early binding be converted or
casted. I use in this case forever this (in the longest notation)

dim myresult as integer = CInt(ds.tables(0).rows(0).item(0))

Have a look at the type convert functions in VBNet, that is one of the
benefits upon other languages from VBNet that those are so powerfull.

http://msdn.microsoft.com/library/de...conversion.asp

I hope this helps?

Cor

"Jon" <Jo*@discussions.microsoft.com> schreef in bericht
news:B9**********************************@microsof t.com...
i have a dataset with a few datatable inside.
most of my table are have values as in integer or double.

but everything i read my table out
e.g. "row.Item("ItemName").ToString

I always need to use the "ToString" method to read the entry out, which
means
i need to convert it with Integer.Parse().....then store it to another
integer...then do calculation...then store it back to the datatable using
the
ToString method again.
Theres just too many convertion!!

I am thinking is that a way to read out the value in datatable as a
integer
straight away?

I tried using ".value", but it seems doesn't work, i cannot load it into
an
integer or Double.

any ideas please! thankyou.

Nov 21 '05 #2
Jon
thanks!

"Cor Ligthert" wrote:
Jon,

The Items are object and should be with early binding be converted or
casted. I use in this case forever this (in the longest notation)

dim myresult as integer = CInt(ds.tables(0).rows(0).item(0))

Have a look at the type convert functions in VBNet, that is one of the
benefits upon other languages from VBNet that those are so powerfull.

http://msdn.microsoft.com/library/de...conversion.asp

I hope this helps?

Cor

"Jon" <Jo*@discussions.microsoft.com> schreef in bericht
news:B9**********************************@microsof t.com...
i have a dataset with a few datatable inside.
most of my table are have values as in integer or double.

but everything i read my table out
e.g. "row.Item("ItemName").ToString

I always need to use the "ToString" method to read the entry out, which
means
i need to convert it with Integer.Parse().....then store it to another
integer...then do calculation...then store it back to the datatable using
the
ToString method again.
Theres just too many convertion!!

I am thinking is that a way to read out the value in datatable as a
integer
straight away?

I tried using ".value", but it seems doesn't work, i cannot load it into
an
integer or Double.

any ideas please! thankyou.


Nov 21 '05 #3
Jon
sorry Cor,1 more question, How good is cInt compare to Integer.Parse?
in performance and speed? because they both do the same thing right?
and i believe Convert.Int too... but i just wonder which is better in
performance wise as i have lots of conversion of integer and double variable.
Nov 21 '05 #4
Jon,

The convert functions are the adviced ones in VBNet. See this pages for this
and that as well for your other performance questions.

Do not think that functions in the Microsoft VisualBasic namespace extention
are slower than in the base Net namespace, for me it is what is the
functionality of such a function. The MVB Replace has by instance more
posibilities than the base replace. Here is the MVB replace slower than the
base one. The Find however is faster than the indexof, where the last has
more posibilities. But it is forever about nanoseconds or parts of that.

However I seldom (never) use MVB functions wherein is the index used. That
One index confuses me to much. But that is by instance not with the convert
functions.

http://msdn.microsoft.com/library/de...tchPerfOpt.asp

I hope this gives some ideas?

Cor

"Jon" <Jo*@discussions.microsoft.com>
sorry Cor,1 more question, How good is cInt compare to Integer.Parse?
in performance and speed? because they both do the same thing right?
and i believe Convert.Int too... but i just wonder which is better in
performance wise as i have lots of conversion of integer and double
variable.

Nov 21 '05 #5

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

Similar topics

2
by: Programatix | last post by:
Hi, I'm working on a project which includes WebServices and Windows Form application. The Windows Form application will call the WebServices to retrieve data from database. The data will be...
5
by: Grant | last post by:
Hello, How come when I add a new row to my dataset table it shows up as changed (agencyData.Haschanges() = True) but when I delete a row the dataset thinks here are no...
4
by: Hans [DiaGraphIT] | last post by:
Hi! I want to export a dataset to an excel file. I found following code on the net... ( http://www.codeproject.com/csharp/Export.asp ) Excel.ApplicationClass excel = new ApplicationClass();...
16
by: Geoff Jones | last post by:
Hi Can anybody help me with the following, hopefully simple, question? I have a table which I've connected to a dataset. I wish to add a new column to the beginning of the table and to fill...
1
by: Wes Hutton via .NET 247 | last post by:
I am trying to pass a data object (set or row) into a functionbyref, and have the same issue either way. In the maincontroller function, I have no issues accessing any parts of mydataset. If I...
3
by: Anon | last post by:
I made this class to encrypt my DataSet before saving it to disk. So, first in the main program I write the DataSet to XML in a MemoryStream. I pass this stream to the E_File sub, which encrypts...
0
by: c.w.browne | last post by:
Hi, Ive had a bit of a look around for other people with this problem and cant find anything that solves it in my case, so I'm afraid im going to have to bother you all with a post of my own. ...
1
by: Mac | last post by:
I'm trying to validate input from an xml source to a dataset in dotnet2.0. As far as I can see, type errors correctly cause an exception, but values that are the correct type but do not satisify...
2
by: SmartbizAustralia | last post by:
Hi, This seems to be a neglected bit of info as everyone gets carried away with data binding examples instead. Can simply use the datareader as below: Private Sub PopulateControls1() Dim...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.