GUID Primary Key In SqlDataSoure UpdateCommand Won't Work

G

Guest

Environment: VS2005, C#, SQLServer 2005
Error Message: Object Must Implement IConvertible

I'm using a FormView whose DataSourceID = SqlDataSource1

SqlDataSource1 has an update command whose WHERE clause references an GUID
column in the underlying table,ie, WHERE AddrGUID = @AddrGUID

AddrGUID is the primary key on the table and the FormView
DataKeyNames=AddrGUID.

When the EditItemTemplate is showing the fields to update and I click the
Submit button, I get the Object "Must Implement IConvertible" error.

No SqlDataSource_OnUpdating event occurs, which I believe it should.

How can I use update statements in a SqlDataSource whose table has a
uniqueidentifier/GUID as a primary key?
 
G

Guest

Just solved it. The GridView, FormView must use strings for the GUIDs, so the
SqlDataSource must convert the guids to strings. All SqlDataSource parameters
are to be typed as Strings.

The SqlDataSource SelectCommand must use:
SELECT Convert(varchar(100),AddrGUID) As AddrGUID, ... WHERE
Convert(varchar(100),AddrGUID) = @StringGUID

and the SqlDataSource UpdateCommand must use:
UPDATE table SET ..... WHERE Convert(varchar(100),AddrGUID) = @StringGUID
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top