title: Response.Redirect using query string
body: <p>Okay so I've just written my own "add a book to the database" ASP.net page that looks like so:</p>
  
  <blockquote>
  <pre><code>&lt;div class="addbook"&gt;&lt;br /&gt;If you feel that we&amp;#39;ve forgotten a book
  that you love, please fill out this form 
  below to help us keep the site fresh and dynamic!
  &lt;h3&gt;Title:&lt;/h3&gt;&lt;asp:TextBox ID="tb_booktitle" runat="server"&gt;&lt;/asp:TextBox&gt;
  &lt;h3&gt;Author:&lt;/h3&gt;&lt;asp:TextBox ID="tb_bookauthor" runat="server"&gt;&lt;/asp:TextBox&gt;
  &lt;h3&gt;Publication Date:&lt;/h3&gt;&lt;asp:TextBox ID="tb_bookpubyear" runat="server" &gt;&lt;/asp:TextBox&gt;    &lt;asp:CompareValidator
  ID="CompareValidatorTextBox1" runat="server"
  ControlToValidate="tb_bookpubyear"
  Type="Date"
  Operator="DataTypeCheck" 
  ErrorMessage="Date must be in the DD/MM/YYYY format)" ForeColor="Red"
  /&gt;
  &lt;h3&gt;Number of Pages:&lt;/h3&gt;&lt;asp:TextBox ID="tb_bookpages" runat="server"&gt;&lt;/asp:TextBox&gt;&lt;asp:RangeValidator ID="RangeValidator1" runat="server" 
      ControlToValidate="tb_bookpages" 
      ErrorMessage="Please enter a number." ForeColor="Red" 
      MaximumValue="9999999" MinimumValue="1" SetFocusOnError="True"&gt;&lt;/asp:RangeValidator&gt;
  
  
  &lt;h3&gt;Publisher:&lt;/h3&gt;&lt;asp:TextBox ID="tb_publisher" runat="server"&gt;&lt;/asp:TextBox&gt;
  &lt;h3&gt;Book Cover:&lt;/h3&gt;
  &lt;asp:FileUpload ID="fu_picture" runat="server" /&gt;
  &lt;h3&gt;Your Rating:&lt;/h3&gt;
  &lt;p&gt;    
      &lt;asp:RadioButtonList ID="rbl_Stars" runat="server" 
      RepeatDirection="Horizontal" Width="142px"&gt;
      &lt;asp:ListItem&gt;1&lt;/asp:ListItem&gt;
      &lt;asp:ListItem&gt;2&lt;/asp:ListItem&gt;
      &lt;asp:ListItem&gt;3&lt;/asp:ListItem&gt;
      &lt;asp:ListItem&gt;4&lt;/asp:ListItem&gt;
      &lt;asp:ListItem&gt;5&lt;/asp:ListItem&gt;
  &lt;/asp:RadioButtonList&gt;
  &lt;/p&gt;
  &lt;p&gt;
      &lt;asp:Button ID="btn_submission" runat="server" Text="Upload Book!" /&gt;
  &lt;/p&gt;
  </code></pre>
  </blockquote>
  
  <p>And the code behind:</p>
  
  <blockquote>
  <pre><code>Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  
  End Sub
  
  Protected Sub btn_submission_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btn_submission.Click
      Dim myGUID = Guid.NewGuid()
  
      Dim newFileName As String = myGUID.ToString() &amp; ".jpg"
      Dim fileLocationOnServerHardDisk = Request.MapPath("img/thumb") &amp; "/" &amp; newFileName
      fu_picture.SaveAs(fileLocationOnServerHardDisk)
      Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("BookMeetConnString").ConnectionString)
      Dim SqlString As String = "Insert into booklist(Title,Author,PublicationDate,Pages,Publisher,imgurl,AverageRating)
  Values (@f1,@f2,@f3,@f4,@f5,@f6,@f7)"
      Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
      cmd.CommandType = CommandType.Text
      cmd.Parameters.AddWithValue("@f1", tb_booktitle.Text)
      cmd.Parameters.AddWithValue("@f2", tb_bookauthor.Text)
      cmd.Parameters.AddWithValue("@f3", tb_bookpubyear.Text)
      cmd.Parameters.AddWithValue("@f4", tb_bookpages.Text)
      cmd.Parameters.AddWithValue("@f5", tb_publisher.Text)
      cmd.Parameters.AddWithValue("@f6", "img/thumb/" &amp; newFileName)
      cmd.Parameters.AddWithValue("@f7", rbl_Stars.SelectedValue)
      oleDbConn.Open()
      cmd.ExecuteNonQuery()
      Response.Redirect("detail.aspx?ID={0}")
  
  End Sub
  
  Protected Sub rbl_Stars_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles rbl_Stars.SelectedIndexChanged
  
  End Sub 
  End Class
  </code></pre>
  </blockquote>
  
  <p>As you can see in the code behind above, once the connection to the database has been made, i want to redirect to the detail.aspx (which is a page showing a single book record from the database and associated content) using a query string to show the record that was just added . But I receive an error like so:</p>
  
  <blockquote>
    <p>Input string was not in a correct format. Description: An unhandled
    exception occurred during the execution of the current web request.
    Please review the stack trace for more information about the error and
    where it originated in the code.</p>
    
    <p>Exception Details: System.FormatException: Input string was not in a
    correct format.</p>
    
    <p>Source Error:</p>
    
    <p>An unhandled exception was generated during the execution of the
    current web request. Information regarding the origin and location of
    the exception can be identified using the exception stack trace below.</p>
    
    <p>Stack Trace:</p>
    
    <p>[FormatException: Input string was not in a correct format.]<br>
    System.Number.StringToNumber(String str, NumberStyles options,
    NumberBuffer&amp; number, NumberFormatInfo info, Boolean parseDecimal)
    +10722195    System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +145<br>
    System.String.System.IConvertible.ToInt32(IFormatProvider provider)
    +46    System.Convert.ChangeType(Object value, TypeCode typeCode, IFormatProvider provider) +297<br>
    System.Web.UI.WebControls.Parameter.GetValue(Object value, String
    defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean
    ignoreNullableTypeChanges) +126<br>
    System.Web.UI.WebControls.Parameter.GetValue(Object value, Boolean
    ignoreNullableTypeChanges) +63<br>
    System.Web.UI.WebControls.Parameter.get_ParameterValue() +40<br>
    System.Web.UI.WebControls.ParameterCollection.GetValues(HttpContext
    context, Control control) +247<br>
    System.Web.UI.WebControls.SqlDataSourceView.InitializeParameters(DbCommand
    command, ParameterCollection parameters, IDictionary exclusionList)
    +257    System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments
    arguments) +589<br>
    System.Web.UI.DataSourceView.Select(DataSourceSelectArguments
    arguments, DataSourceViewSelectCallback callback) +21<br>
    System.Web.UI.WebControls.DataBoundControl.PerformSelect() +138<br>
    System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +30<br>
    System.Web.UI.WebControls.GridView.DataBind() +4<br>
    System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +105 
    System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls()
    +75    System.Web.UI.Control.EnsureChildControls() +83    System.Web.UI.Control.PreRenderRecursiveInternal() +42<br>
    System.Web.UI.Control.PreRenderRecursiveInternal() +168<br>
    System.Web.UI.Control.PreRenderRecursiveInternal() +168<br>
    System.Web.UI.Control.PreRenderRecursiveInternal() +168<br>
    System.Web.UI.Control.PreRenderRecursiveInternal() +168<br>
    System.Web.UI.Page.ProcessRequestMain(Boolean
    includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    +974</p>
  </blockquote>
  
  <p>How would I go about achieving what I am trying to do?</p>