Object Must Implement IConvertible is a BUG non solved?

L

lcorrias

i try to do a simple insert using SQLDataSource and a Stored Procedure

I try all night and always have this error



Object Must Implement IConvertible



I can't understand where I wrong..



Looking around I understand is maybe a typecasting problema but I not
find nothing more understeable..

Could someone tell me why Microsoft release this SQLdatasorce making
more difficult a simple insert?

If someone could help me to fix this problem please



Here is the code

------------------------------------------------------------------------------------------------------------



Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnSave.Click





Try

SqlDataSource1.Insert()



Catch ex As Exception

Response.Write(ex.ToString)

Finally

SqlDataSource1.Dispose()





End Try



End Sub

------------------------------------------------------------------------------------------------------------



<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:CommerceTemplate %>"

InsertCommandType="StoredProcedure"
InsertCommand="dbo.StoredProcedure1">

<InsertParameters>

<asp:ControlParameter ControlID="DropDownListCategory"
Name="@CategoryID" PropertyName="SelectedValue"

Type="Int32" />

<asp:ControlParameter ControlID="DropDownListCategory"
Name="@ModelNumber" PropertyName="SelectedValue"

Type="String" />

<asp:ControlParameter ControlID="txtModelName"
Name="@ModelName" PropertyName="Text"

Type="String" />

<asp:ControlParameter ControlID="txtProductImage"
Name="@ProductImage" PropertyName="Text"

Type="String" />

<asp:ControlParameter ControlID="txtUnitCost"
Name="@UnitCost" PropertyName="Text"

Type="Decimal" />

<asp:ControlParameter ControlID="txtDescription"
Name="@Description" PropertyName="Text"

Type="String" />

<asp:ControlParameter ControlID="txtWeight"
Name="@Weight" PropertyName="Text" Type="Decimal" />

<asp:ControlParameter ControlID="txtDiscount"
Name="@Discount" PropertyName="Text"

Type="Decimal" />

<asp:ControlParameter ControlID="chkIsActive"
Name="@isActive" PropertyName="Checked"

Type="Boolean" />

<asp:ControlParameter ControlID="DropDownListAuthors"
Name="@IDAuthor" PropertyName="SelectedItem"

Type="Int32" />

</InsertParameters>

</asp:SqlDataSource>

------------------------------------------------------------------------------------------------------------





ALTER PROCEDURE dbo.StoredProcedure1



@CategoryID int,

@ModelNumber nvarchar(50),

@ModelName nvarchar(50),

@ProductImage nvarchar(50),

@UnitCost money,

@Description varchar(500),

@weight money,

@IsActive bit,

@DiscountPerCent int,

@IDAuthor int



AS



INSERT INTO dbo.CMRC_Products (



CategoryID,

ModelNumber,

ModelName,

ProductImage,

UnitCost,

Description,

weight,

IsActive,

DiscountPerCent,

IDAuthor

)



VALUES (



@CategoryID,

@ModelNumber,

@ModelName,

@ProductImage,

@UnitCost,

@Description,

@weight,

@IsActive,

@DiscountPerCent,

@IDAuthor

)



SELECT @@IDENTITY as [NewID]



------------
 
B

bruce barker \(sqlwork.com\)

its a binding issue. something you bind to the datasource is not the
datatype you specified, and does not support converting. a quick look at
your code and you'll see:

<asp:ControlParameter
ControlID="DropDownListAuthors"
Name="@IDAuthor"
PropertyName="SelectedItem"
Type="Int32" />

SelectedItem returns a listitem, which is not an int, nor does t upport an
the IConvertible interface which cold be use to getan int value. you
probably wanted SelectedValue

-- bruce (sqlwork.com)


i try to do a simple insert using SQLDataSource and a Stored Procedure

I try all night and always have this error



Object Must Implement IConvertible



I can't understand where I wrong..



Looking around I understand is maybe a typecasting problema but I not
find nothing more understeable..

Could someone tell me why Microsoft release this SQLdatasorce making
more difficult a simple insert?

If someone could help me to fix this problem please



Here is the code

------------------------------------------------------------------------------------------------------------



Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnSave.Click





Try

SqlDataSource1.Insert()



Catch ex As Exception

Response.Write(ex.ToString)

Finally

SqlDataSource1.Dispose()





End Try



End Sub

------------------------------------------------------------------------------------------------------------



<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:CommerceTemplate %>"

InsertCommandType="StoredProcedure"
InsertCommand="dbo.StoredProcedure1">

<InsertParameters>

<asp:ControlParameter ControlID="DropDownListCategory"
Name="@CategoryID" PropertyName="SelectedValue"

Type="Int32" />

<asp:ControlParameter ControlID="DropDownListCategory"
Name="@ModelNumber" PropertyName="SelectedValue"

Type="String" />

<asp:ControlParameter ControlID="txtModelName"
Name="@ModelName" PropertyName="Text"

Type="String" />

<asp:ControlParameter ControlID="txtProductImage"
Name="@ProductImage" PropertyName="Text"

Type="String" />

<asp:ControlParameter ControlID="txtUnitCost"
Name="@UnitCost" PropertyName="Text"

Type="Decimal" />

<asp:ControlParameter ControlID="txtDescription"
Name="@Description" PropertyName="Text"

Type="String" />

<asp:ControlParameter ControlID="txtWeight"
Name="@Weight" PropertyName="Text" Type="Decimal" />

<asp:ControlParameter ControlID="txtDiscount"
Name="@Discount" PropertyName="Text"

Type="Decimal" />

<asp:ControlParameter ControlID="chkIsActive"
Name="@isActive" PropertyName="Checked"

Type="Boolean" />

<asp:ControlParameter ControlID="DropDownListAuthors"
Name="@IDAuthor" PropertyName="SelectedItem"

Type="Int32" />

</InsertParameters>

</asp:SqlDataSource>

------------------------------------------------------------------------------------------------------------





ALTER PROCEDURE dbo.StoredProcedure1



@CategoryID int,

@ModelNumber nvarchar(50),

@ModelName nvarchar(50),

@ProductImage nvarchar(50),

@UnitCost money,

@Description varchar(500),

@weight money,

@IsActive bit,

@DiscountPerCent int,

@IDAuthor int



AS



INSERT INTO dbo.CMRC_Products (



CategoryID,

ModelNumber,

ModelName,

ProductImage,

UnitCost,

Description,

weight,

IsActive,

DiscountPerCent,

IDAuthor

)



VALUES (



@CategoryID,

@ModelNumber,

@ModelName,

@ProductImage,

@UnitCost,

@Description,

@weight,

@IsActive,

@DiscountPerCent,

@IDAuthor

)



SELECT @@IDENTITY as [NewID]
 
L

lcorrias

Thanks bruce for your answer..

The error, very probabilly, is a binding eeror but i try to pass every
kind of value without solution..
The error is still the same..

at the end i have fired the subroutine using sqlquery and passing
parameter beetwen '' like the old asp 3.0..

Something in the new asp.net don't working..

Luigi :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top