Quantcast
Channel: SQL Server Compact & SQLite Toolbox
Viewing all articles
Browse latest Browse all 2796

Commented Issue: CreateIfNotExists assumes default connection string [9919]

$
0
0
The function CreateIfNotExists refers to the static ConnectionString. However, it is possible to call the DataContext constructor with a *different* connection string ... which then appears to be ignored.

I appreciate that most of the time the connection strings as templated by the toolbox are what is required but it is possible that alternative strings may be required. Indeed, it may be appropriate to build ConnectionString and ConnectionStringReadOnly from a filename (which could be passed) rather than assuming that anyone calling the constructor will have passed one of the two static connection strings.

Thanks for a great toolbox! Saved me a lot of headaches.

Philip
Comments: ** Comment from web user: pcolmer **

In the code built by the toolbox in my project, CreateIfNotExists starts with:

using (var db = new GedcomDataContext(MyProjectDataContext.ConnectionString))

where it looks like MyProjectDataContext.ConnectionString refers to the public static string that is defined just above the class constructor.

For my project, I've worked around it by alterting the start of CreateIfNotExists so that I can pass a connectionstring to that function and it uses that instead of the static. A simple workaround would be to overload CreateIfNotExists - one with no parameters (which then uses the static string) and one with one string parameter which is the string to use instead.

Philip


Viewing all articles
Browse latest Browse all 2796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>