Solved

How to convert smallint to int

Posted on 2006-06-08
5
2,328 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 500 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project

730 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