-
January 11th, 2006, 12:29 AM
#1
nput 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.RaisePostDataChangedEvent()
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
-
January 25th, 2006, 04:09 AM
#2
Re: nput string was not in a correct format
Hi,
You haven't set the CommandText for cmdCategoriesById. That may be the reason for the error.
Regards
Kishore.
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
|
Click Here to Expand Forum to Full Width
|