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.
Bug related to SqliteParameters class
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
use
or
So, instead of
Code: Select all
const string strSql = @"
select LanguageID, LanguageName
from Language
where LanguageID = @LanguageID;
";
Code: Select all
const string strSql = @"
select LanguageID, LanguageName
from Language
where LanguageID = @LanguageID
";
Code: Select all
const string strSql = @"
select LanguageID, LanguageName
from Language
where LanguageID = @LanguageID;";
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 .
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 .