473,326 Members | 2,173 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,326 software developers and data experts.

GUID Primary Key In SqlDataSoure UpdateCommand Won't Work

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?


--
Thank you kindly,

Dan Sikorsky BA, BSCE, MCS
Aug 3 '06 #1
1 2026
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
--
Thank you kindly,

Dan Sikorsky BA, BSCE, MCS
"Dan Sikorsky" wrote:
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?


--
Thank you kindly,

Dan Sikorsky BA, BSCE, MCS
Aug 3 '06 #2

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

Similar topics

24
by: Ilija_G | last post by:
Hi, Is there any replace for "Select @@identity" that could return "just inserted" GUID as a primary key? Has anyone tested what's faster, working with Guid or Autonumber ?
3
by: Robert Chapman | last post by:
I know that this should be impossible, yet it is happening... I have some c# code that uses a method scoped variable of type Guid. The code assigns Guid.NewGuid() to the variable. This value is...
3
by: Jeffry van de Vuurst | last post by:
Hi, I'm working with Guids as the primary key of some of my tables. In my code, I'm working with those Guids. Now I was wondering what is the best way to work with Guids (in terms of...
1
by: Omer kamal | last post by:
When in database(.mdb) the primary key have fields size type "Replication ID" it creates Guid. I tried to create string of Guid and insert it but did it not work. Control.databindings.add(),...
4
by: Grey | last post by:
I used .NET to generate a GUID for creating a new record in Access DB as primary key. Is it guaratee to be unique in the DB as the GUID is not generate in DB?? If so, is that mean GUID is generated...
12
by: Geoff Jones | last post by:
Hi How do I set a primary key to be a GUID? That is, using the following code, I can set an integer primary key, but how do I change it to a GUID? Dim databaseCommand As OleDbCommand = New...
1
by: Jeff | last post by:
ASP.NET 2.0 This problem occur using the basic version of SQL Server 2005 which get installed when installing Visual Studio 2005! I have inserted a record in the Test table. But when I try to...
4
by: newbtemple | last post by:
New to programming and got a question. I'm trying to add a primary key in vb.net to a table I made in SQL. The table in SQL does not have a primary key. I pull that table into my program and...
4
by: Marc | last post by:
Hi, I don't get it I cannot get this to work, can somebody give me a hint Table1 contains a field Id which is a GUID as primary key and DATA a string, I want to insert a new row but it does not...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.