Solved

Input string was not in a correct format

Posted on 2006-11-08
12
341 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now