I've got this project that I wrote in VS2010 as a WinForms project. I'm not writing it in VS2012 as a WPF project. I have a referenced DLL (DailyReport
). Inside DailyReport
is a method called GetUniqueDates()
. It looks like this:
public List<string> GetUniquesDates()
{
var dates = new List<string>();
const string query = "SELECT date FROM hdd_local_data_v1_2";
try
{
// Exception here on the connection creation
using (var connection = new SqlConnection(ConnectionStringFile))
{
using (var command = new SqlCommand(query, connection))
{
connection.Open();
using (var reader = command.ExecuteReader())
{
while (reader.Read())
{
for (var i = 0; i < reader.FieldCount; i++)
{
dates.Add(reader.GetValue(i).ToString());
}
}
}
}
}
}
catch (Exception ex)
{
Logger.Error(ex.Message);
}
dates.Sort();
return dates.Distinct().ToList();
}
The ConnectionStringFile
is set in the constructor, and looks like this:
ConnectionStringFile = @"Data Source=C:\hdd_data\Rubicon.hdd;Version=3;New=False;Compress=True;";
Now, in my VS2010 WinForms project, this method worked just fine. However, in my VS2012 WPF project, I get an exception where I noted above. And the exception is:
keyword not supported 'version'.
The database is a SQLite database. I've tried removing the version
keyword, but then I'd get the exception:
keyword not supported 'new'.
My question is: Why would the connection work in my WinForms project and not my WPF project? Is there something that changed when dealing with database connections?
Also, please note, this isn't a question about parameterized queries and the like. So, if possible, please those comments to yourself. Thank you.
The issue I was having was because I was trying to create a SqlConnection
instead of a SQLiteConnection
. Making that change solved my issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With