[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to convert smallint to int

Posted on 2006-06-08
5
Medium Priority
?
2,477 Views
Last Modified: 2007-12-19
How do you convert a sql server defined field smallint to a int? Fields UnitsOnOrder and UnitsInStock are defined as smallint in sql server.  I get an error using the "Convert.ToInt16".

int intUnitsOnOrder;
int intUnitsInStock;
TextBox txtUnitsInStock = (TextBox)e.Item.Cells[4].Controls[0];
TextBox txtUnitsOnOrder = (TextBox)e.Item.Cells[5].Controls[0];
intUnitsOnOrder = Convert.ToInt16(txtUnitsOnOrder.ToString());  ???? error

 

0
Comment
Question by:Hojoformo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 2000 total points
ID: 16866906
try this:

intUnitsOnOrder = Int16.Convert(txtUnitsOnOrder.Text);  

AW
0
 
LVL 16

Expert Comment

by:Edwin_C
ID: 16867051
It should be

intUnitsOnOrder = Convert.ToInt16(txtUnitsOnOrder.Text);  
0
 
LVL 16

Expert Comment

by:Edwin_C
ID: 16867054
oops, it should be

intUnitsOnOrder = Convert.ToInt32(txtUnitsOnOrder.Text);  

because you need an int type.
0
 
LVL 7

Expert Comment

by:pradeepsudharsan
ID: 16867330
Hi,
u can try like this
int a;
            
a=int.Parse(TextBox1.Text);

Regards
Pradeep
0
 
LVL 16

Expert Comment

by:Edwin_C
ID: 16898999
Hi hojoformo

May I know what kind of language you are using?  I thought you are using C# but there should be no Int16.Convert().  Are you sure it works for you?

Edwin
0

Featured Post

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question