Solved

Input string was not in a correct format

Posted on 2006-11-08
12
340 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Query datatable in LINQ 6 39
GridDataView 6 44
Expando 4 33
Form design in vb.net 7 18
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

708 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

11 Experts available now in Live!

Get 1:1 Help Now