erikkl2000 Posted June 19, 2005 Posted June 19, 2005 I am clicking on a datalist option inside a control that is inside a webform and when i get transferred to the corresponding page I am receiving this error. At first i was receiveing an error stating that the stored procedure is expecting (@IDDepartment), and now I am receiving this error message. Thanks =========The Error============== Server Error in '/ConstructionSuperCenterCom' Application. -------------------------------------------------------------------------------- Object must implement IConvertible. 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.InvalidCastException: Object must implement IConvertible. Source Error: Line 45: Line 46: Dim dr As SqlDataReader Line 47: dr = cmd.ExecuteReader(CommandBehavior.CloseConnection) Line 48: cnn.Close() Line 49: dl8.DataSource = dr Source File: C:\Inetpub\wwwroot\ConstructionSuperCenterCom\Controls\WindowTreatmentHome_Control.ascx.vb Line: 47 Stack Trace: [invalidCastException: Object must implement IConvertible.] System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) +742 System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) +45 ConstructionSuperCenterCom.WindowTreatmentHome_Control.Page_Load(Object sender, EventArgs e) in C:\Inetpub\wwwroot\ConstructionSuperCenterCom\Controls\WindowTreatmentHome_Control.ascx.vb:47 System.Web.UI.Control.OnLoad(EventArgs e) +67 System.Web.UI.Control.LoadRecursive() +35 System.Web.UI.Control.LoadRecursive() +98 System.Web.UI.Control.LoadRecursive() +98 System.Web.UI.Page.ProcessRequestMain() +750 =======The Code Behind========== Dim cnn As New SqlConnection("Data Source=DESKTOP; Initial Catalog=ConstructionSuperCenter; Trusted_Connection=Yes") cnn.Open() Dim cmd As New SqlCommand("GetBlindCompanys", cnn) cmd.CommandType = CommandType.StoredProcedure Dim IDDepartment As SqlParameter = New SqlParameter("@IDDepartment", SqlDbType.Int, 4) IDDepartment.Value = IDDepartment cmd.Parameters.Add(IDDepartment) Dim dr As SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection) cnn.Close() dl8.DataSource = dr dl8.DataBind() End Sub End Class =========================== Here is the control that is passing the stored procedure... ========================= <P> <asp:datalist id="dl2" runat="server" RepeatColumns="0" Height="184px" BorderColor="White"> <ItemTemplate> <table style="BORDER-BOTTOM: #66cccc 3px double"> <tr> <td valign="middle" align="left"> <A href='<%# DataBinder.Eval(Container.DataItem, "DepartmentID", "WindowTreatment_Home.aspx?IDDepartment={0}") %>'> <img src='Images/<%# DataBinder.Eval(Container.DataItem, "DepartmentImage") %>' border="0"> </a> </td> <td valign="top"><table> <tr> <td valign="top" align="left"> <a href='WindowTreatment_Home.aspx?IDDepartment=<%# DataBinder.Eval(Container.DataItem, "DepartmentID") %>'> <span class="ProductListHead"> <%# DataBinder.Eval(Container.DataItem, "DepartmentName") %> </span></a> </td> </tr> <tr> <td valign="bottom"> <table width="200"> <tr> <td><span class="ProductListItem"> <%# DataBinder.Eval(Container.DataItem, "DepartmentDescription") %> </span> </td> </tr> </table> </td> </tr> <tr> <td><table> <tr> <td><IMG SRC="images\10x10spacer.gif"></td> </tr> </table> </td> </tr> <tr> <td><img src="images\10x10spacer.gif"></td> </tr> <tr valign="bottom"> <td align="right" valign="bottom"><a href='WindowTreatment_Home.aspx?IDDepartment=<%# DataBinder.Eval(Container.DataItem, "DepartmentID") %>'><span class="ViewDetails"><font color="#9D0000"><b><u>View Details</u></b></font></span> </a> </td> </tr> </table> </table> </ItemTemplate> </asp:datalist></P> Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.