Bug related to SqliteParameters class

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for SQLite
Post Reply
AleksandarBeograd
Posts: 3
Joined: Wed 14 Apr 2010 12:32

Bug related to SqliteParameters class

Post by AleksandarBeograd » Thu 15 Apr 2010 10:09

Hi!
Here is the bug I found when I want to use SqliteParameters:

I created one database table (Language) and inserted a few records. Here is the code:

CREATE TABLE Language (
LanguageID varchar(10) PRIMARY KEY NOT NULL,
LanguageName varchar(30) NOT NULL UNIQUE,
IsDefault boolean NOT NULL DEFAULT 0
);

INSERT INTO Language (LanguageID, LanguageName, IsDefault) VALUES ('SR', 'Srpski', '0');
INSERT INTO Language (LanguageID, LanguageName, IsDefault) VALUES ('EN', 'English', '1');
INSERT INTO Language (LanguageID, LanguageName, IsDefault) VALUES ('SV', 'Svenska', '0');
INSERT INTO Language (LanguageID, LanguageName, IsDefault) VALUES ('NO', 'Norsk', '0');
INSERT INTO Language (LanguageID, LanguageName, IsDefault) VALUES ('DE', 'Deutch', '0');
COMMIT;

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

I tried to read a record from this table by using the following C# code:

const string languageId = "EN";
const string strSql = @"
select LanguageID, LanguageName
from Language
where LanguageID = @LanguageID;
";

var dt = new DataTable
{
Locale = System.Globalization.CultureInfo.InvariantCulture
};

using (var sqlConnect = new SQLiteConnection(@"Data Source=D:\Projects\TestDevArtSqlite\DbModel\TestDb.db;FailIfMissing=True"))
{
var command = new SQLiteCommand(strSql, sqlConnect);

var param = new SQLiteParameter("@LanguageID", SQLiteType.Text) {Value = languageId};
command.Parameters.Add(param);

var dataAdapt = new SQLiteDataAdapter(command);
dataAdapt.Fill(dt);
}

dataGridResults.DataSource = dt;
------

One record should be returned, but the result set is empty!

If I change code and write value of the parameter directly in string 'strSql', it works fine. I mean, if replace parameter '@LanguageID' in 'strSql' with 'EN' value, it works.

Am I missing something? Is there any option I didn't set or it's really a bug?
Thank you.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Mon 19 Apr 2010 11:51

Thank you for the bug report. We will fix the problem. As a temporary workaround, please remove extra empty line from your CommandText.
So, instead of

Code: Select all

const string strSql = @"
select LanguageID, LanguageName
from Language
where LanguageID = @LanguageID;
";
use

Code: Select all

const string strSql = @"
select LanguageID, LanguageName
from Language
where LanguageID = @LanguageID
";
or

Code: Select all

const string strSql = @"
select LanguageID, LanguageName
from Language
where LanguageID = @LanguageID;";

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Mon 19 Apr 2010 16:20

The issue with an extra empty line in CommandText is fixed. Look forward to the next build of dotConnect for SQLite. I will post here when it is available for download.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Fri 21 May 2010 14:22

dotConnect for SQLite v 2.90 is released!
It can be downloaded from http://www.devart.com/dotconnect/sqlite/download.html (trial version) or from Registered Users' Area (for users with valid subscription only).
For more information, please refer to http://www.devart.com/forums/viewtopic.php?t=18033 .

Post Reply