Solved

How to convert smallint to int

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

724 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