Thanks

        The connection was indeed getting closed. On further debugging, I found 
this is because the SQL created by the designer for the update command requires 
a matching of all fields in the WHERE clause. Below are some examples from the 
designer.cs file:

this._adapter.UpdateCommand.CommandText = @"UPDATE 
[main].[sqlite_default_schema].[Assignment] SET [Course_Id] = @Course_Id, 
[Name] = @Name, [Description] = @Description, [Pointspossible] = 
@Pointspossible, [Downloadpath] = @Downloadpath, [AssignedDate] = 
@AssignedDate, [DueDate] = @DueDate, [CreateDate] = @CreateDate WHERE 
(([ASSIGNMENT_ID] = @ORIGINAL_ASSIGNMENT_ID) AND ([COURSE_ID] = 
@ORIGINAL_COURSE_ID) AND ([NAME] = @ORIGINAL_NAME) AND ((@ISNULL_DESCRIPTION = 
1 AND [DESCRIPTION] IS NULL) OR ([DESCRIPTION] = @ORIGINAL_DESCRIPTION)) AND 
([POINTSPOSSIBLE] = @ORIGINAL_POINTSPOSSIBLE) AND ((@ISNULL_DOWNLOADPATH = 1 
AND [DOWNLOADPATH] IS NULL) OR ([DOWNLOADPATH] = @ORIGINAL_DOWNLOADPATH)) AND 
([ASSIGNEDDATE] = @ORIGINAL_ASSIGNEDDATE) AND ([DUEDATE] = @ORIGINAL_DUEDATE) 
AND ([CREATEDATE] = @ORIGINAL_CREATEDATE))";
                                
this._adapter.UpdateCommand.CommandText = @"UPDATE 
[main].[sqlite_default_schema].[Course] SET [Name] = @Name, [Description] = 
@Description WHERE (([COURSE_ID] = @ORIGINAL_COURSE_ID) AND ([NAME] = 
@ORIGINAL_NAME) AND ((@ISNULL_DESCRIPTION = 1 AND [DESCRIPTION] IS NULL) OR 
([DESCRIPTION] = @ORIGINAL_DESCRIPTION)))";
            
        When I removed the redundant matching columns, leaving only the primary 
key, the error went away as expected. I believe that the extra conditions 
generated in the UPDATE command are unusual.

        So my question is: is this a bug or a feature in System.Data.SQLite

Thanks
Manish

-----Original Message-----
From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] 
On Behalf Of Joe Mistachkin
Sent: Monday, March 26, 2012 2:47 AM
To: 'General Discussion of SQLite Database'
Subject: Re: [sqlite] Concurrency violation: the UpdateCommand affected 0 of 
the expected 1 records


Agrawal, Manish wrote:
>
> 1. Database connection not valid for getting number of changes
>       At System.Data.SQLite.SQLiteConnection.get_Changes()
> 
> 2. Database connection not valid for getting last insert rowid
>       At System.Data.SQLite.SQLiteConnection.get_LastInsertRowId()
> 
> 3. Database connection not valid for getting maximum memory used
>       At System.Data.SQLite.SQLiteConnection.get_MemoryHighwater()
> 
> 4. Database connection not valid for getting memory used
>       At System.Data.SQLite.SQLiteConnection.get_MemoryUsed()
> 

Those exceptions indicate that the connection has been closed somehow.

--
Joe Mistachkin

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to