dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Input string was not in a correct format

Hybrid View

  1. #1
    Join Date
    Nov 2005
    Posts
    46

    Input string was not in a correct format

    Input string was not in a correct format.
    Line 94 seems to be the culprit but I don't know why


    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.

    Exception Details: System.FormatException: Input string was not in a correct format.

    Source Error:


    Line 92: SqlConnection1.Open()
    Line 93: Dim dreader As SqlClient.SqlDataReader
    ***********************************************************************
    ***********************************************************************
    Line 94: dreader = cmdCategoriesById.ExecuteReader(CommandBehavior.SingleRow)

    **********************************************************************************
    **********************************************************************************
    Line 95: If dreader.Read() Then
    Line 96: txtCategoryName.Text = dreader(1)


    Source File: c:\inetpub\wwwroot\VBNetUnleashed\WebApplication3\WebForm1.aspx.vb Line: 94

    Stack Trace:


    [FormatException: Input string was not in a correct format.]
    System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
    cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
    System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)
    WebApplication3.WebForm1.ddlCategoryID_SelectedIndexChanged(Object sender,
    EventArgs e) in c:\inetpub\wwwroot\VBNetUnleashed\WebApplication3\WebForm1.aspx.vb:94
    System.Web.UI.WebControls.ListControl.OnSelectedIndexChanged(EventArgs e)
    System.Web.UI.WebControls.DropDownList.System.Web.UI.IPostBackDataHandler.RaisePostDataCha ngedEvent()
    System.Web.UI.Page.RaiseChangedEvents()
    System.Web.UI.Page.ProcessRequestMain()


    Here is my code:

    Private Sub ddlCategoryID_SelectedIndexChanged(ByVal sender As System.Object,
    ByVal e As System.EventArgs) Handles ddlCategoryID.SelectedIndexChanged
    Dim categoryid As String
    categoryid = ddlCategoryID.SelectedItem.Text
    cmdCategoriesById.Parameters("@categoryid").Value = categoryid
    SqlConnection1.Open()
    Dim dreader As SqlClient.SqlDataReader
    dreader = cmdCategoriesById.ExecuteReader(CommandBehavior.SingleRow)
    If dreader.Read() Then
    txtCategoryName.Text = dreader(1)
    txtCategoryDescription.Text = dreader(2)
    End If
    dreader.Close()
    SqlConnection1.Close()
    End Sub

    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    Handles btnSave.Click
    With cmdCategoriesUpdate
    .Parameters("@categoryid").Value = ddlCategoryID.SelectedItem.Text
    .Parameters("@categoryname").Value = txtCategoryName.Text
    .Parameters("@categorydescription").Value = txtCategoryDescription.Text
    End With
    SqlConnection1.Open()
    cmdCategoriesUpdate.ExecuteNonQuery()
    SqlConnection1.Close()

    End Sub
    End Class

  2. #2
    Join Date
    Dec 2003
    Posts
    2,750
    What is the CommandText value of cmdCategoriesById?
    Paul
    ~~~~
    Microsoft MVP (Visual Basic)

  3. #3
    Join Date
    Nov 2005
    Posts
    46
    Commandtext value is:
    SELECT CategoryID, CategoryName, Description FROM Categories WHERE (CategoryID = @categoryid)

Similar Threads

  1. Input string was not in a correct format.error
    By naijacoder in forum ASP.NET
    Replies: 6
    Last Post: 11-10-2005, 03:54 AM
  2. Input string was not in a correct format
    By mdengler in forum ASP.NET
    Replies: 0
    Last Post: 11-26-2002, 03:32 PM
  3. How to format A: drive as another User
    By Gregory B. Brooks in forum VB Classic
    Replies: 0
    Last Post: 01-29-2002, 06:35 PM
  4. verify local admin
    By Patrick Comeau in forum VB Classic
    Replies: 6
    Last Post: 03-22-2001, 11:50 PM
  5. Please help me -- urgent -- deadlock error
    By chandra in forum VB Classic
    Replies: 0
    Last Post: 06-22-2000, 07:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center