473,399 Members | 4,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Object Must Implement IConvertible is a BUG non solved?


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]

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

Aug 9 '06 #1
2 2348
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)
<lc******@yahoo.comwrote in message
news:11**********************@75g2000cwc.googlegro ups.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]

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

Aug 9 '06 #2
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 :)

Aug 10 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Bill Cart | last post by:
This is a question from a confused newbe.I have an oldDbCommand component called oleDbCmdAddDemoReq and an oldDbConnection called oleDbConDemoReq on a web form. I have the following code: ...
5
by: Leon Shaw | last post by:
I'm trying to insert a record into a sql server 2000 database using a store procedure (vs.net is my develop tool) on the button click event but I keep getting the following error after clicking the...
1
by: George Durzi | last post by:
I want to convert a dataset to type object so I can pass it to a generalized function which accepts an object and adds it to the cache. If I pass it in like: Convert.ChangeType(MyDataSet,...
1
by: Tim::.. | last post by:
Hi can someone please help me with the following error! I keep getting: ERROR: System.InvalidCastException: Object must implement IConvertible. Line 231: PageID =...
4
by: charleswesley | last post by:
I think the problem is with the strPrice variable in the AddToCart() sub. I've been messing with it all morning and can't seem to figure it out. Any ideas? ...
1
by: dan | last post by:
I am using VB.NET 2003 and SQL Server 2000. My program inserts new rows in a SQL table based on data read from a file. I generated the commands and the stored procedures with the DataAdapter...
3
by: dan | last post by:
I am using VB.NET 2003 and SQL Server 2000. My program inserts new rows in a SQL table based on data read from a file. I generated the commands and the stored procedures with the DataAdapter...
1
by: =?Utf-8?B?QkpT?= | last post by:
I have written a Generic method that takes an object, a type, T, and returns a System.Nullable (Of T) depending on whether or not the object IsDBNull. It was working fine until I tried to pass a...
0
by: dan | last post by:
Hi, I've been using a GridView for some time but this is the first time I need to delete a row in the grid whose primary key consists of 2 fields (table columns). I have a table with primary...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.