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("Item Name").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...t hen 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. 4 5432
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*@discussion s.microsoft.com > schreef in bericht
news:B9******** *************** ***********@mic rosoft.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("Item Name").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...t hen 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.
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*@discussion s.microsoft.com > schreef in bericht news:B9******** *************** ***********@mic rosoft.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("Item Name").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...t hen 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.
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.
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*@discussion s.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.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 returned as DataSet.
Now, here's the problem. On .NET Framework 1.1, if any rows in the dataset
returned contain errors (marked by calling the SetColumnError() method or
|
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 changes(agencyData.Haschanges() = False)????
The bizaar thing is the row count before the delete and after is different
so it definately is being deleted but I cannot update my main database table
because the dataset thinks there are no changes?
|
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();
excel.Application.Workbooks.Add(true);
DataTable table = DATASETNAME.Tables;
|
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 it with incremental values e.g. if the tables looks
like this:
23 56
|
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 extract a data row, it has values and is fine. However, when I pass either the whole dataset or just a data rowto another function, it errors out, and in the Locals windowjust has "error: cannot obtain value" against every field. I'vecopied the code...
| |
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 the stream and writes it
out to the FileStream. Now, in the D_File function, I
read the encrypted file into a FileStream, then decrypt
it into a MemoryStream, which I pass back to my DataSet
and Read the XML into the DataSet. The problem I'm...
|
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.
Essentially, I am trying to read in an xml schema and then an xml
document into a dataset using ReadXmlSchema and then ReadXml. When i do
this, i end up with a table in the dataset (which i assume is created
when i read the schema), but no rows...
|
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
xsd:restriction conditions are ingested without a murmur. Is this a bug
or a feature?
Very frustrating.
Evidence:
1) XML data
<?xml version="1.0" encoding="utf-8"?>
|
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 sSql As String
Dim cn As SqlConnection
|
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...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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...
|
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,...
|
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |