We help IT Professionals succeed at work.
Get Started

Failed to convert parameter value from a String to a Int32.

600 Views
Last Modified: 2013-11-08
I have the following code:

 Protected Sub CompleteGridview1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles CompleteGridView1.RowCommand
        Dim currentRowIndex As Integer = Int32.Parse(e.CommandArgument)

        Dim ProductID As String = CompleteGridView1.DataKeys(currentRowIndex).Value
        If Roles.IsUserInRole(Membership.GetUser.UserName.ToString, "ELP_Transport") Then
            Response.Redirect("~/Foxconn/CT/Metrics_Detail_Transport.aspx?Key='" & ProductID & "'")
        Else
            Response.Redirect("~/Foxconn/CT/Metrics_Detail.aspx?Key='" & ProductID & "'")
        End If

    End Sub

which calls the Metrics Detail page on page load:

I get the error on the second line:

Dim CT_Key As SqlParameter = cmd.Parameters.Add("@CT_Key", SqlDbType.Int)
CT_Key.Value = Request.QueryString("Key").ToString

rdr = cmd.ExecuteReader() ---> error: Input string was not in a correct format.


Thank you
Comment
Watch Question
Senior Engineer
CERTIFIED EXPERT
Top Expert 2010
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE