-
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
-
What is the CommandText value of cmdCategoriesById?
Paul
~~~~
Microsoft MVP (Visual Basic)
-
Commandtext value is:
SELECT CategoryID, CategoryName, Description FROM Categories WHERE (CategoryID = @categoryid)
Similar Threads
-
By naijacoder in forum ASP.NET
Replies: 6
Last Post: 11-10-2005, 03:54 AM
-
By mdengler in forum ASP.NET
Replies: 0
Last Post: 11-26-2002, 03:32 PM
-
By Gregory B. Brooks in forum VB Classic
Replies: 0
Last Post: 01-29-2002, 06:35 PM
-
By Patrick Comeau in forum VB Classic
Replies: 6
Last Post: 03-22-2001, 11:50 PM
-
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
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|