Click here to Skip to main content
11,704,315 members (44,433 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: Sqlite
I need to do something where I create a blank database, and then run commands to generate my schema. I have everything worked out as far as I can tell, but for some reason every time I try to connect I get an error saying "Invalid format for parameter C:\Test\test.db"

Here's the code where I get the problem.
               String connectionString = "Data Source=" + filePath+";";
               using (var connection = new SQLiteConnection(filePath))
I have tried it with DataSource or Data Source in the connection string property. I also tried with and without that appended semicolon at the end. The CreateFile works, but then I can't get my connection to open. It throws an exception every time.

Can anyone please help me?
Posted 16-Apr-11 4:46am
Edited 16-Apr-11 4:49am
strogg at 16-Apr-11 13:21pm
you're using 'filepath' to open the connection. I guess u forgot to use connectionString you've created :)
DannyStaten at 16-Apr-11 14:51pm
Wow thanks for the fresh pair of eyes there.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You must pass connectionString to the constructor, not the path

using (var connection = new SQLiteConnection(connectionString))

DannyStaten at 16-Apr-11 14:45pm
LOL thanks. Count that one up as a brain fart that I just needed a fresh pair of eyes on. Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 740
1 OriginalGriff 520
2 Maciej Los 355
3 Andy Lanng 284
4 CPallini 267
0 OriginalGriff 8,824
1 Sergey Alexandrovich Kryukov 8,247
2 CPallini 5,197
3 Maciej Los 4,726
4 Mika Wendelius 3,606

Advertise | Privacy | Mobile
Web04 | 2.8.150819.1 | Last Updated 16 Apr 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100