Solved

Input string was not in a correct format

Posted on 2006-11-08
12
344 Views
Last Modified: 2006-11-18
The code below keeps generating the error Input string was not in a correct format   at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info).  How can I conver it.  Thanks

DataGrid4.CurrentCell = New DataGridCell(hti.Row, hti.Column)
            DataGrid4.Select(hti.Row)
            screenid = DataGrid4.Item(hti.Row, 0)  'Column 1
            DsPAScreen21.Clear()
            SqlDataAdapter2.SelectCommand.Parameters("@paramid").Value = screenid
            SqlDataAdapter2.Fill(DsPAScreen21, "tblPAScreen")
0
Comment
Question by:running32
  • 6
  • 4
  • 2
12 Comments
 
LVL 29

Expert Comment

by:Nightman
ID: 17900706
which line gives you the error?
0
 

Author Comment

by:running32
ID: 17900726
SqlDataAdapter2.SelectCommand.Parameters("@paramid").Value = screenid is giving me the error.

Thanks
0
 
LVL 29

Expert Comment

by:Nightman
ID: 17900750
I would assume that @paramid parameter is a numeric type. What is the value of screenid? Any non-numeric type (or null) will result in a parse error
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:running32
ID: 17900758
I declared it as  Dim screenid As Integer
0
 

Author Comment

by:running32
ID: 17900791
in the sql database it is declared as a int 4
0
 
LVL 29

Expert Comment

by:Nightman
ID: 17900797
And what is the value of screenid at that point?
0
 

Author Comment

by:running32
ID: 17900819
15
0
 

Author Comment

by:running32
ID: 17900871
Actually sorry it appears to be giving the error on SqlDataAdapter2.Fill(DsPAScreen21, "tblPAScreen")
0
 
LVL 14

Expert Comment

by:Ramuncikas
ID: 17900912
The DataGrid4.Item(hti.Row, 0) returns a cell object and there is no way it could be directly converted/casted to integer. If you're trying to get a value of the cell then your code should be changed a bit:

screenid = DataGrid4.Item(hti.Row, 0).Value  'Column 1

In case if referenced cell contains a number whitch can be casted to Integer then your code should not raise errors any more.


HTH
Ramuncikas

0
 
LVL 29

Expert Comment

by:Nightman
ID: 17900932
Ramuncikas appears to have it - give that a try.
0
 

Author Comment

by:running32
ID: 17900937
Additional information: Public member 'Value' on type 'Integer' not found.

If I do that then i get this error.
0
 
LVL 14

Accepted Solution

by:
Ramuncikas earned 500 total points
ID: 17900990
then try
screenid = Convert.ToInt32(DataGrid4.Item(hti.Row, 0).Value)
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

713 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