473,395 Members | 1,422 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

"Input string was not in a correct format." Error when returning DataViewRow as a form property


I've been attempting to pass a chunk of data back from a child Windows form using public properties on the form and have been getting some odd errors. I wanted to return a row of data to avoid creating many public properties on the form to do the same thing. At first I tried returning a DataViewRow. This worked fine until I reached the phone field on the parent table and the code

Child form
public DataRowView SelectedAddres

ge

return drvAddress

Parent form
this.txtBTPhone.Text = fAddrSearch.SelectedAddress["Phone"].ToString( )

produced the following error
-----------------------------------------------------------------------------------------------
An unhandled exception of type 'System.FormatException' occurred in mscorlib.dl

Additional information: Input string was not in a correct format
-----------------------------------------------------------------------------------------------

The phone field is a string data type in the dataset on the child table and the actual value of the field was something like "123-456-7890"

At first, I thought this was because the DataRowView wasn't serializing the type information so I thought that I would try using a DataRow from a strongly-typed dataset like this

Child form
public AddressDataset.AddressRow SelectedAddres

ge

return rwAddress

Parent form
this.txtBTPhone.Text = fAddrSearch.SelectedAddress.Phone

This still didn't work - neither did using System.Convert.ToString() or the ToString method of the data row field. I also noticed that null values produced these same results. I tried using the "IsPhoneNull" method of the typed data row but the problem is that the error occurs before method is invoked. It's as if the type is not known and there is no default type converter that will handle these types of data. Something is obviously assuming that the phone number is an integer data type just because the first character is numeric

The only thing that I thought might be causing this is that it might have something to do with the return statement only returning value types. Has anyone else seen this problem? Is it a bug or by design

John Chorlton
Nov 18 '05 #1
1 3983
OK ...ignore the above post.

For those who want to know, the problem turned out to be due to an assignment to a combo box on the parent form in the statement prior to the phone statement. The value member of the combo box was set to an integer but the SelectedValue that I was assigning was a string - simple. The reason that this threw me off is that the Visual Studio debugger does not break on the combo box assignment line but on the line following the assignment. This still seems strange because it's not consistent with the usual action of the debugger

John
Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Punisher | last post by:
Ok I'm trying to reference a specific node in a tree. TreeNode nodeParentChannel = treeview1.Nodes; It bugs out with this error: Input string was not in a correct format Obviously 1.2 is not...
0
by: phmyhn | last post by:
I have two web pages, one is viewlarger.aspx, another one is shoppingcart.aspx. On the viewlarger.aspx, when clicking "add to cart" image button, the sub appends the id (passed from another page...
1
by: John Chorlton | last post by:
I've been attempting to pass a chunk of data back from a child Windows form using public properties on the form and have been getting some odd errors. I wanted to return a row of data to avoid...
3
by: dan | last post by:
I am using VB.NET 2003 and SQL Server 2000. The program uses ADO.NET . The following instruction: Me.cd_insertDataRecord.ExecuteNonQuery() throws this exception: ">>>ProcessDataRecord/...
1
by: James Pose | last post by:
Convert.Int32 fails for "0" but works fine for all other numbers. This does not work on one machine when "0" it works fine on other machines Convert.ToInt32(“0”); gives exception {"Input...
3
by: Pieter Coucke | last post by:
Hi, When a user types a non numeric-value in a numeric column in a DataGridView, and he tries to leave the cell, he gets this "Input string was not in a correct format."-exception. Is there a...
13
by: Jen | last post by:
One user of my application is experiencing an exception "input string not in correct format". But it makes no sense where it is occurring. It is occurring when a string from a textbox ("172") is...
1
by: Anjan Bhowmik | last post by:
I am getting this exception while binding data to Gridview. I have a control parameter that accepts a integer value from a TextBox. If i provide a invalid value, i get that exception. But can't...
9
muaddubby
by: muaddubby | last post by:
Hi I'm running into a scenario with a DataSet that has a schema loaded into it, tries to then load data (that matches the schema), and fails with a "Input string was not in a correct format"...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.