yiskang / csharp-sqlite

Automatically exported from code.google.com/p/csharp-sqlite
Other
0 stars 0 forks source link

2 problems I encountered when switching from System.Data.SQLite #138

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
1. Connection string.
I used connection strings like
"Data Source=C:\\temp\\data.sqlite"
Creation of SqliteConnection with these connection strings causes 
InvalidOperationException("Invalid connection string: invalid URI")

While I know how to fix that, I still thought I'd let you know.

2. Parameter prefix
I'm used to decorating my command parameters with the "@" sign.
These parameters are not recognized,
IndexOutOfRangeException("The specified name does not exist: " + parameterName);
is thrown.

Original issue reported on code.google.com by felix.ob...@netcologne.de on 27 Jan 2012 at 2:28

GoogleCodeExporter commented 8 years ago
If you have a patch for these changes, I'd like to include them in the project

Original comment by noah.hart@gmail.com on 26 Mar 2012 at 7:16

GoogleCodeExporter commented 8 years ago
Sorry, it took a while, but here you go.

Original comment by felix.ob...@netcologne.de on 16 Apr 2012 at 12:59

Attachments:

GoogleCodeExporter commented 8 years ago
The problem with adding just:

} else if (File.Exists(tvalue)) {
   db_file = tvalue;

...as a fix for invalid URI issue is that it assumes that the DB file exists on 
the disk. However if I want C#-SQLite to create the database from scratch (like 
would happen with System.Data.SQLite) it will still throw the exception as the 
file does not exist yet. 

Reading sources for System.Data.SQLite, it looks like it does not make 
assumptions about the path passed as "Data Source" as long as it's not empty. 
And all the logic is in the Open() method anyways, just passing 
ConnectionString does not trigger any validation about it yet, unlike here in 
C#-SQLite where property setter does validation already.

Maybe the last else -block in the validation should just assign path as-is to 
the db_file as it actually does when compiling with WINDOWS_PHONE set? Or 
(maybe better solution overall) separate validation for tokens "uri" and "data 
source" completely from each other as they are logically two separate concerns 
anyways.

Original comment by ka...@saunamaki.fi on 19 Apr 2012 at 10:12