converting a string to number or integer

erm... how is this done in c#? 

or convert an object to and number or integer?
I need to get the below as a number or int:

TotalRecords = conSelProdCount.ExecuteScalar().ToString();

So i can use it in:

ProductItem[] arrNews = new ProductItem[TotalRecords];
int rwcnt = 0;
while ( dtrProducts.Read())
string NewVar = dtrProducts["ProductName"].ToString();
arrNews[rwcnt] = new ProductItem();
arrNews[rwcnt].rowcount = @TotalRecords;
arrNews[rwcnt].ProductName = dtrProducts["ProductName"].ToString();
rwcnt += 1;

return arrNews;

10/2/2003 7:25:01 AM 91979 articles. 3 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 9


Why do you convert conSelProdCount.ExecuteScalar() to a string? I guess the database result is an integer. So just put the result in a integer variable and work directly with it.
Not sure if syntax is correct, I don't really know the syntax of C#.

Int TotalRecords = conSelProdCount.ExecuteScalar();

Michael Gysin

Webmaster of a small ISP :-)

All my code suggestions are and will be written in
10/2/2003 7:42:19 AM
You might try parse for converting.

int TotalRecordsInt = int.Parse(TotalRecords);
int TotalRecordsInt = int.Parse(conSelProdCount.ExecuteScalar());
Mike Hofstede


10/2/2003 8:29:14 AM

Similar Artilces:

Is there any function to convert string to integer in
Is there any function to convert string to integer in thank you very much.As Heinlein said "specialization is for insects" explore beyond the universe. Hi There, You can do this Dim Val as String = "50" Dim i As Integer = Convert.ToInt32(Val)DC517Don't forget to click "Mark as Answer" on the post that helped you. This credits that member, earns you a point and marks your thread as Resolved. thank you very much dennisAs Heinlein said "specialization is for insects" explore beyond the universe. Hi There, No problem, always welcome...

converting string to integer, subtracting strings.
Hi,  I have a textbox into which the user will enter a number I then have button that when the user clicks, the number taken from the textbox will be subtracted by one or more(depending on the users situation) and displayed in a label.   The problem i am having at the moment is that when i attempt to do this an error comes up saying that "the operator '-' cannot be used with string or int". String Score1 = txtScore1.Text: String netScore1;   netScore1 = Score1 - 1; lblNetScore1.Text = netScore1;   I have ...

[COMMIT] Fixes to PMC integer, number, started PMC strings
Pretty much says it all. ...

VS.NET 2005 is ignoring in web.config strict="true". I get no error when I try this: Dim x As Integer = "string"
Hello,I have this in my VS.NET 2005 web.config <compilation debug="true" strict="true" explicit="true">When I do this in my vb code:Dim x As Integer = "string"I get no error. When I hit compilation I also get no error. What am I doing wrong?Thanks for helping!Regards,J. Bauer It's a bug of some sort See this response by Scott Guthrie Unfortunately we don’t have a GUI based way to configure this. L It is something we will make sure gets added back in, though, with the next...

VB.NET: How to convert hexadecimal number to normal (decimal) number?
Hi to all VB.NET function Hex() converts numbers to hexadecimal strings, is there any reverse function that converts hexadecimals back to numbers?? Thanks, Hooker Hi, how are you? In C#, we have something like: Convert.ToInt32(string strValue, int Base)... So I basically can do: Int iDecimal = Convert.ToInt32("AF8", 16); I'm pretty sure there must be something like it on VB.Net. Hope this Helps, Covo"Everything should be made as simple as possible, but not simpler", A. Einstein That should work, thanks. I'm fine, BTW...

Getting error while converting string to double: Input string was not in correct format
Select Case LocalMeasuringUnitText Case "Currency" 'do the conversion hereDim ConversionRate As Double = GetConversionRate(_LanguageID)   Dim UKValue As Double 'String.Format("{0:c}", SelectedRow(rowloop).Item("TransData").ToString()) Dim varValue As Object = NothingDim Stringvalue As Object = SelectedRow(rowloop).Item("TransData").ToString.Trim 'varValue = Double.TryParse(Stringvalue, varValue) 'CType(Stringvalue, System.Double) 'UKValue = Convert.ToDouble(Stringvalue) / GetConversionRate(ConfigurationManager.AppS...

Converting a string to an integer
I have an identification card that contains a group of characters within a bar code. I need to extract the first 6 characters and convert them to a Social Security Account Number (SSAN).  In cold fusion I use InputBaseN(stringvalue, 32) and all is well.  I am having difficulty achieving the same result in VB. Any help or suggestion would be appreciated since I am new to all this. <JP> you can do a substring. perhaps something like : convert.toint16(stringvalue.substring(1,6))***********************Dinakar NethiLife is short. Enjoy it.*********************** I know the 6...

convert string to number?
Hi, I have a problem where a number read from a file is being treated as a string by perl (I think!). I am using the module RSPerl which is an interface between Perl and the statistical language R. When i read a column of numbers from a file and pass it to the perl/R function i get an "invalid 'type' (character) of argument" error. The reason i think this is a problem on the Perl side is shown by this pseudocode: while(<FILE>){ ... stuff to extract $value from each row ... push(@list1, $value); } @list2 = (100.2, 232.333, 344.2); # these ...

Converting string to integer
 I have a textbox which the user will enter a number into.  I then have a label control which will perform a maths operation and write out the resulting answer; atleast this is whant I want anyway however this is not happening.The code I have so far is   1 Protected Sub btnWork_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnWork.Click2 3 Dim Work As Integer4 Work = txtWorkSet5 lblS.Text = ("Work * 0.4" & " kg").ToString6 7 End Sub  I get an...

Converting string to an integer
I have an page in which a user inputs a SSN in the proper format 555-55-5555 I want to put tha into an Interger field in the sql database. How to I convert my value in the textbox to an interger that the database will accept. Are these seperate text inputs like so: 555 = first text box 55 = second 5555 = third IF so you can tie them together with the string builder class and then convert them to an int with "int.Parse()", post your code and I can better show you. SamSam CromerSenior .NET Developer First you have to strip the "-" s...

Convert String to Number
I am running PB 7.03 build 10047 on Windows 2000. How do I convert a string value to number in the DataWindow script? I can convert number to string using String(ll_value), but how do I do the reverse? The help file says I should be able to use Number(ls_value), but the error checker tells me that is an unknown function. Thanks for your help. dec('123') or long('123') or integer('123') -- Kim Berghall Sisu Group, Inc. remove no_spam. <Scott_Emery> wrote in message news:72D1C6C14C517376005C20...

convert string to number
Hello, if I use the sprintf function it would give me a number STRING, but = not number, so I have to trick the string to become number by adding and su= btracting the number with 1. Is there a better way than this ? I want it to= be a number data type and not string.=0A=0Ae.g =0A=0Amy $strNumber =3D spr= intf("%04d", 123);=0Amy $number =3D $strNumber + 1 - 1; # to trick Perl to = convert to number datatype instead of string. =0A=0A=0AThanks,=0A=0AWilliam= =0A=0ASend instant messages to your online friends http://uk.messenger.yaho= On Sun, Jun 15, 2008 at 8:09 PM, Wi...

Convert number to integer
Right now I have a form that has people enter there numbers, I do some calculations and then send the projections back to them. In the form I have them enter the value without commas. I would like to make easier for people by letting them enter their values with commas (i.e. 20,000). How do I filter out the commas so that I have just the numeric value? I have to be able to evaluate thousand and millions, no decimal values. cheers; Hi there, this really isnt to difficult, you should be able to do something like this cint(replace(num, ",","")) Set your input variable to be a string, the c...

Convertion numbers to strings
Hello! I have some numbers in data type "Numeric". The task is to write expression wich combines prefix, number and suffix. The number must have no spare zero's on tale. Linke in example: "NDS 20%" "SN 1.5%" "ANT 0.25%" The slyboot server makes all the numbers with the same length of fract. part. like "20.00000" and I couldn't cope with this for two weeks already. I don't know of a way to do that in SQL Anywhere. -- Jim Egan [TeamPS] Dealer Solutions, Inc. Houston, TX See you at the Powersoft User Confer...

Web resources about - converting a string to number or integer -

Facebook Begins Converting Users To HTTPS
Are you willing to sacrifice a little bit of speed for a lot more safety? Facebook is asking that very question with its announcement that it ...

Facebook No Longer Converting Groups Into Pages
Back when Facebook first launched Facebook Pages, many businesses and brands who had built up substantial audiences in their Facebook Groups ...

Vert - simply converting for iPhone, iPad, and iPod touch on the iTunes App Store
Get Vert - simply converting on the App Store. See screenshots and ratings, and read customer reviews.

Converting SIM Card to Micro SIM Card - Flickr - Photo Sharing!
Place new Micro SIM into the iPhone SIM card tray

Ayaan Hirsi Ali on Converting Muslims to Christianity - YouTube
Complete video at: Ayaan Hirsi Ali explains her support of missionary ...

Converting dry air to water: solution to Broken Hill's water crisis gains support
A one-man crusade by a Broken Hill resident to solve the historic town's water crisis by introducing air to water converters is gaining support. ...

Click go fears of converting print files
Is there a way to convert a print queue item to a .RTF or .PDF file? I like to save or email them. - The Sydney Morning Herald

Sudanese woman ordered to hang under sharia law for converting to Christianity gives birth
Khartoum, Sudan: A Christian Sudanese woman sentenced to hang for apostasy has given birth in jail, a Western diplomat said on Tuesday.

Imams warn against radicalism to Aboriginal inmates converting to Islam
The prison system has enlisted the help of ASIO to crack down on radicalisation behind bars amid revelations that Aboriginals are converting ...

Converting the world's companies one by one - The Science Show - ABC Radio National (Australian Broadcasting ...
Image: Trucks carrying logs make their way up a road in Jambi, Indonesia. A vast area of the Sumatran forest, and orangutan habitat, is being ...

Resources last updated: 2/10/2016 11:55:17 PM