ExecuteCommand empty parameter error

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for SQLite
Post Reply
LordFjord
Posts: 18
Joined: Thu 22 Apr 2010 07:55

ExecuteCommand empty parameter error

Post by LordFjord » Thu 05 Aug 2010 13:21

Hello,
I am using dotConnect SQLite professional (version 2.90.146.0).
The problem occurs when i am using ExecuteCommand on the sqlite context where a parameter contains an emtpy string.
In this case, the parameter value is simply gone, and the value of the next parameter takes its place, shifting all paramters after it to the left.
The error does not occur if i replace the empty strings with a blank.


A small example, maybe this helps to reproduce it on your side:

The table, nothing fancy

Code: Select all

CREATE TABLE MYTABLE (
UID NVARCHAR(36) NOT NULL PRIMARY KEY,
DATA1 INT NULL,
DATA2 INT NULL,
DATA3 NVARCHAR(128) NULL,
DATA4 DATETIME NULL,
DATA5 NVARCHAR(128) NULL
);
Some sample code how i fill the table (sqliteContext is the datacontext for the sqlite db file):

Code: Select all

string sqlCommand = "INSERT INTO MYTABLE (UID, DATA1, DATA2, DATA3, DATA4, DATA5) VALUES ({0}, {1}, {2}, {3}, {4}, {5});";
sqliteContext.ExecuteCommand( sqlCommand,
Guid.NewGuid().ToString(),
0,
1,
string.Empty, // if I use some replacement string like " " then it works
DateTime.UtcNow,
"SomeText");
The date ends up in the DATA3 string instead of in DATA4. The DATA4 and DATA5 values are empty as well.

LordFjord
Posts: 18
Joined: Thu 22 Apr 2010 07:55

Post by LordFjord » Fri 06 Aug 2010 07:53

A few additions:

If I rewrite the code not to use ExecuteCommand but generate the context objects and use InsertOnSubmit with SubmitChanges, things work fine.

If I rewrite the code to use ExecuteCommand and build the SQL string including parameters manually, things work fine. However in this case I would need to implement something to catch all the reserved characters and the like to not mess up the SQL.

If I used ExecuteCommand and replace the empty strings with a " ", then it works, BUT only if this happens on a single parameter. Once I replace two or more, the query is messed up in a similar way as I described it in my previous post.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Fri 06 Aug 2010 13:18

I have made a test with code similar to the code you have provided using the latest 2.90.152 build and everything went OK.
Could you please upgrade to the latest build of dotConnect for SQLite?
Please notify me if anything goes wrong.

LordFjord
Posts: 18
Joined: Thu 22 Apr 2010 07:55

Post by LordFjord » Fri 13 Aug 2010 07:30

I have managed to reproduce the problem with a small test project.
I couldnt update my system to the new version yet as my project is in the final phases.

I have sent the test project to the devart support email address.

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Mon 16 Aug 2010 12:05

Thank you for your assistance, we've reproduced the problem on the latest 2.90.152 build. We will investigate it and inform you about the results as soon as possible.

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Fri 24 Sep 2010 16:53

We have fixed the issue, the fix is available in the new 2.90.170 build of dotConnect for SQLite. The build can be downloaded from
http://www.devart.com/dotconnect/sqlite/download.html
(the trial version) or from Registered Users' Area (provided that you have an active subscription):
http://secure.devart.com/

The detailed information about the fixes and improvements implemented in dotConnect for SQLite 2.90.170 is available at
http://www.devart.com/forums/viewtopic.php?t=19071

Post Reply