Jump to content
Software FX Community

Input string was not in a correct format


User (Legacy)

Recommended Posts

Posted

Binding to a ADO.Net datasource sometimes results in the following error:

"Input string was not in a correct format"

I did not find anything on your support site, but a google search showed an

old bug from 2002, Q6052000 - but this is not an XML data provider.

I am using MSSQL.

It works for some queries, not others.

Scenario is:

I create a chart, save the complete layout to a SQL table (binary).

When the chart is selected, load the layout (works without error) and then

bind to the datasource for that chart, which is an ADO.Net datatable.

Any ideas?

Posted

This can happen if you are trying to convert data to a type and the 

conversion fails, throwing this exception.

I would need to have a sample program to reproduce the problem to be sure

but what I think is happening is that you have a field defined as either a

value or X-Value but the field in the DB is actually a string, if the actual

string is a number (e.g. "1.00") it will convert it correctly but if it is

not (e.g. "text") it will throw this exception.

So check your Fields collection (if you are setting any) and verify the type

of each field in your data source.

--

Francisco Padron

www.chartfx.com

ChartFXDS.xml

Posted

No conversion, but I discovered the error does not occur as long as I bind 

the datasource BEFORE importing the Layout.

With some datatables the order did not matter, but I have found a few where

it does.

"Software FX" <noreply@softwarefx.com> wrote in message

news:UveqxiLGHHA.1368@webserver3.softwarefx.com...

> This can happen if you are trying to convert data to a type and the

> conversion fails, throwing this exception.

>

> I would need to have a sample program to reproduce the problem to be sure

> but what I think is happening is that you have a field defined as either a

> value or X-Value but the field in the DB is actually a string, if the

> actual string is a number (e.g. "1.00") it will convert it correctly but

> if it is not (e.g. "text") it will throw this exception.

>

> So check your Fields collection (if you are setting any) and verify the

> type of each field in your data source.

>

> --

> Francisco Padron

> www.chartfx.com

>

Posted

Francisco -  is this ´working as designed´ (bind before changing layout).

Not a problem to code that way, more of a concern that it may be indicative

of another issue.

Regards,

Tim

"TOPry" <topry@nospam.com> wrote in message

news:WWSaZsLGHHA.1368@webserver3.softwarefx.com...

> No conversion, but I discovered the error does not occur as long as I bind

> the datasource BEFORE importing the Layout.

> With some datatables the order did not matter, but I have found a few

> where it does.

>

>

>

> "Software FX" <noreply@softwarefx.com> wrote in message

> news:UveqxiLGHHA.1368@webserver3.softwarefx.com...

>> This can happen if you are trying to convert data to a type and the

>> conversion fails, throwing this exception.

>>

>> I would need to have a sample program to reproduce the problem to be sure

>> but what I think is happening is that you have a field defined as either

>> a value or X-Value but the field in the DB is actually a string, if the

>> actual string is a number (e.g. "1.00") it will convert it correctly but

>> if it is not (e.g. "text") it will throw this exception.

>>

>> So check your Fields collection (if you are setting any) and verify the

>> type of each field in your data source.

>>

>> --

>> Francisco Padron

>> www.chartfx.com

>>

>

>

Posted

I was originally saving .FileContents.All as binary to the database, 

thinking that when I bound a different dataset the chart would update to

reflect that current dataset?

It appears that the error is related to that - ie if I save .All, then

import that layout and bind to a different dataset, this error is thrown.

If I exclude .Data and .DataBind from the layout, the error does not occur.

"Software FX" <noreply@softwarefx.com> wrote in message

news:4ASI1wUGHHA.1368@webserver3.softwarefx.com...

> TO change the layout you are importing an XML ? If so, can you please

> attach the XML.

>

> --

> Francisco Padron

> www.chartfx.com

>

Posted

This appears it may be related to the bug with Parameters in the designer.

Since I cannot currently bind to a stored procedure that has parameters and

use the designer to layout the grid, I created an sproc that had no

parameters, bound to that and then created and saved the layout. I use this

method create my default charts, saving the layout for each.

Within my application, the user selects from the pre-defined charts, the

layout and other info is loaded from the database, a corresponding sproc

invoked and the resulting dataset bound to the chart.

This works in some instances but not all.

The charts on which it is failing have a x/y layout that is different from

those that work.

Specifically when I use the ´Adjust Data to Chart´ feature within the

designer, these are detected has having multiple chart layouts. Those that

are working, do not have multiple potential layouts. So it is not unique to

those with parameters, just those with parameters that have multiple

potential layouts. If I save the layout with the default layout (top one in

the attached image) - no error. Unfortunately, is it the bottom layout that

I need and which causes the error.

See images attached.

"Software FX" <noreply@softwarefx.com> wrote in message

news:4ASI1wUGHHA.1368@webserver3.softwarefx.com...

> TO change the layout you are importing an XML ? If so, can you please

> attach

> the XML.

>

> --

> Francisco Padron

> www.chartfx.com

>

>

Posted

Attached are XML layouts for the chart mentioned in my post above.

ChartLayout1.XML and 2 were created when bound to the sproc without

parameters.

#1 is the top (default layout) in the earlier jpg and #2 is the bottom (the

one I want). Both of these cause the error when bound to a dataset - any

dataset.

ChartLayout3.XML was created when bound to the sproc that has parameters,

but due to the current issue with the designer I cannot change the layout.

This one does not cause the error.

Hopefully, this helps.

"Software FX" <noreply@softwarefx.com> wrote in message

news:4ASI1wUGHHA.1368@webserver3.softwarefx.com...

> TO change the layout you are importing an XML ? If so, can you please

> attach

> the XML.

>

> --

> Francisco Padron

> www.chartfx.com

>

>

Attachments.zip

Posted

The Multiple Layout screen is displayed when the selection of fields 

indicate a possibility for the use of crosstab.

In your case, Description and MonthName (assuming they are strings) can be

used only as column and row headings respectively, and RefCount the only

numeric field as the series value. So you end up with two choices.

The problem you are having is that you are saving the BindingSettings in the

XML, these setting contain information used by the CrossTab data provider,

but if you later read the data WITHOUT using the CrossTab Data Provider then

you will have a problem.

The situation is very complex and it is hard to pinpoint exactly what you

need to change, the only way for me to tell for certain would be to review a

sample program that reproduces the problem, something I can run in my box.

--

Francisco Padron

www.chartfx.com

Posted

Actually, in my application I am saving as binary. I sent the XML files in 

response to your request.

I have tried saving all of the data as well as excluding .Data and

.DataBind - with same results.

I will create a sample that duplicates the issue - should I attach it as a

zip in this forum or send it to a separate email address?

"Software FX" <noreply@softwarefx.com> wrote in message

news:fls$dJhGHHA.1368@webserver3.softwarefx.com...

> The Multiple Layout screen is displayed when the selection of fields

> indicate a possibility for the use of crosstab.

>

> In your case, Description and MonthName (assuming they are strings) can be

> used only as column and row headings respectively, and RefCount the only

> numeric field as the series value. So you end up with two choices.

>

> The problem you are having is that you are saving the BindingSettings in

> the XML, these setting contain information used by the CrossTab data

> provider, but if you later read the data WITHOUT using the CrossTab Data

> Provider then you will have a problem.

>

> The situation is very complex and it is hard to pinpoint exactly what you

> need to change, the only way for me to tell for certain would be to review

> a sample program that reproduces the problem, something I can run in my

> box.

>

> --

> Francisco Padron

> www.chartfx.com

>

Posted

Saving to Bin , if you save the FileContents.DataBind would have the same 

results, it is just easier to see it in the XML, when I saw this section of

your XML:

- <DATASOURCESETTINGS>

- <FIELDS>

- <ITEM>

<NAME>RefCount</NAME>

<DISPLAYNAME>RefCount</DISPLAYNAME>

<USAGE>RowHeading</USAGE>

</ITEM>

- <ITEM>

<NAME>MonthNr</NAME>

<DISPLAYNAME>MonthNr</DISPLAYNAME>

<USAGE>Value</USAGE>

</ITEM>

- <ITEM>

<NAME>Description</NAME>

<DISPLAYNAME>Description</DISPLAYNAME>

<USAGE>ColumnHeading</USAGE>

</ITEM>

</FIELDS>

</DATASOURCESETTINGS>

I realized that the problem is related to using Crosstab.

--

Francisco Padron

www.chartfx.com

Posted

Sample attached

"Software FX" <noreply@softwarefx.com> wrote in message

news:E2WqX3jGHHA.2608@webserver3.softwarefx.com...

> PS: You can attach the ZIP file here, unless it contains private

> information, in that case you can e-mail it to support and reference my

> name.

>

> --

> Francisco Padron

> www.chartfx.com

>

>

Posted

As suspected, the problem is with CrossTab.

ChartFXLayoutError.bin contains FieldMap information that's to be used by

the CrossTab provider, but instead it is being used directly by Chart FX.

When saved, FileContents.DataBinding was on.

You must either clear the flag BEFORE exporting or you must clear the Field

settings right after exporting, before databinding:

Chart1.DataSourceSettings.Fields.Clear()

--

Francisco Padron

www.chartfx.com

TestChartFXLayoutError.zip

Posted

In the example within the btnLoadError.Click event, please see the comments 

where I have the following comments:

´ChartFXLayoutErrorNoDataorDataBind.bin uses ´And Not FileContents.Data And

Not FileContents.DataBind´

´no errors occur, but the layout is incorrect - it is using the default

layout vs the crosstab defined

That layout file does what you suggest and the error does not occur, but the

layout is not correct. How do I get it to display the crosstab properly?

Regards,

Tim

"Software FX" <noreply@softwarefx.com> wrote in message

news:GSlMD%23kGHHA.1368@webserver3.softwarefx.com...

> As suspected, the problem is with CrossTab.

>

> ChartFXLayoutError.bin contains FieldMap information that´s to be used by

> the CrossTab provider, but instead it is being used directly by Chart FX.

>

> When saved, FileContents.DataBinding was on.

>

>

>

> You must either clear the flag BEFORE exporting or you must clear the

> Field settings right after exporting, before databinding:

>

>

>

> Chart1.DataSourceSettings.Fields.Clear()

>

>

> --

> Francisco Padron

> www.chartfx.com

>

Posted

The problem is that the CrossTab Data Provider settings are NOT saved into 

the file, the Chart doesn´t keep a pointer to it, it uses it in databinding

but it doesn´t keep it.

In order to read the data the same way it was read before importing the

chart, you will need to replicate what the wizard does, if you look at the

form code generated by the wizard, you will see something like this (C#):

ChartFX.WinForms.DataProviders.CrosstabDataProvider crosstabDataProvider1 =

new ChartFX.WinForms.DataProviders.CrosstabDataProvider();

crosstabDataProvider1.DataSource = <binding source>;

this.chart1.DataSource = crosstabDataProvider1;

Note: You need to add a reference to ChartFX.Winforms.Data.dll to your

project.

In your case, after reading the file that contains the Data Binding settings

requiring crosstab (ChartFXLayoutError.bin) you must do the following

instead of directly assigning a DataSource to the chart:

Dim crossTabDataProvider As New

ChartFX.WinForms.DataProviders.CrosstabDataProvider

crossTabDataProvider.DataSource = ds.Tables(0)

Chart1.DataSource = crossTabDataProvider

--

Francisco Padron

www.chartfx.com

Posted

Thank you - that did resolve the issue.

I had used another tool that saved everything within the layout files and

had not noticed the reference to a separate data provider for crosstabs

within the sample project.

Regards,

Tim

"Software FX" <noreply@softwarefx.com> wrote in message

news:ZSMHcruGHHA.2340@webserver3.softwarefx.com...

> The problem is that the CrossTab Data Provider settings are NOT saved into

> the file, the Chart doesn´t keep a pointer to it, it uses it in

> databinding but it doesn´t keep it.

>

> In order to read the data the same way it was read before importing the

> chart, you will need to replicate what the wizard does, if you look at the

> form code generated by the wizard, you will see something like this (C#):

>

> ChartFX.WinForms.DataProviders.CrosstabDataProvider crosstabDataProvider1

> = new ChartFX.WinForms.DataProviders.CrosstabDataProvider();

> crosstabDataProvider1.DataSource = <binding source>;

>

> this.chart1.DataSource = crosstabDataProvider1;

>

> Note: You need to add a reference to ChartFX.Winforms.Data.dll to your

> project.

>

> In your case, after reading the file that contains the Data Binding

> settings requiring crosstab (ChartFXLayoutError.bin) you must do the

> following instead of directly assigning a DataSource to the chart:

>

> Dim crossTabDataProvider As New

> ChartFX.WinForms.DataProviders.CrosstabDataProvider

>

> crossTabDataProvider.DataSource = ds.Tables(0)

>

> Chart1.DataSource = crossTabDataProvider

>

>

> --

> Francisco Padron

> www.chartfx.com

>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...