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
Solved

Input string was not in a correct format

Posted on 2006-11-08
12
343 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Pagebreak issue while printing the aspx page 3 34
Crystal reports vb.net 2 52
FInd Image Control Gridview 3 19
Convert Ctime to date time in textfile? 7 28
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 shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

790 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