Solved

Input string was not in a correct format

Posted on 2006-11-08
12
342 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

816 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

12 Experts available now in Live!

Get 1:1 Help Now