This is a migrated thread and some comments may be shown as answers.

Failed to convert parameter value from a string to a int32 error on parameterized query

1 Answer 411 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mike Theos
Top achievements
Rank 1
Mike Theos asked on 18 Sep 2009, 09:11 PM
I am trying to pull data from a database with a stored procedure that takes an integer for the parameter. I used the video http://tv.telerik.com/reporting/video/telerik-reporting-+-design-time-support-for-parameterized-queries as a guide but cannot get the report to work properly.

If I put a value in the Collection Editor for the parameter, I get data returned, but only for the parameter that is hard coded. If I remove that value, I get an error saying 'Failed to convert parameter value from a String to a Int32.

Here is the code for my button. I have created the getter/setter on my ReportViewer object for the parameter OrderIDParam as per the video's instructions. I ran it through debug and the value being passed to the setter is correct.

 

protected void btnRun_Click(object sender, EventArgs e)

 

{

(ReportViewer1.Report

as ReportViewer).OrderIDParam = int.Parse(txtOrderID.Text);

 

ReportViewer1.RefreshReport();

}

Any help would be appreciated. Thanks.

1 Answer, 1 is accepted

Sort by
0
Mike Theos
Top achievements
Rank 1
answered on 21 Sep 2009, 05:45 PM
I solved the problem.

In my getter/setter I was using a value of zero for the parameter index. That parameter is actually the return value, not my input parameter. I changed the index to 1 in my get and my set  and now it's working.
Tags
General Discussions
Asked by
Mike Theos
Top achievements
Rank 1
Answers by
Mike Theos
Top achievements
Rank 1
Share this question
or