<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Snipplr - pckujawa</title>
<link>http://snipplr.com/users/pckujawa/language/c-sharp/tags/sqlserver</link>
<description>Recent snippets posted on Snipplr.com</description>
<language>en-us</language>
<pubDate>Thu, 20 Jun 2013 02:45:14 GMT</pubDate>
<item>
<title>(C#) Set the directory (connection string) for an SQL Server Database Connection</title>
<link>http://snipplr.com/view/10502/set-the-directory-connection-string-for-an-sql-server-database-connection/</link>
<description><![CDATA[ <p>This snippet is actually tested for SQL Server Compact Edition (CE) 3.5, but it will probably work for other SQL Server editions. Once you have an SQL CE db up and running, you can set the connection string to point to any directory and database by simply using the |DataDirectory| string in the dbConnectionString Property (created by default when you create the database connection) and then relocating the location to which |DataDirectory| points by calling AppDomain.CurrentDomain.SetData("DataDirectory", @"C:\Path\To\DB"). Since the dbConnectionString property appends \dbName.sdf, we leave that part off of the SetData argument.

The code below sets the data directory to the common application data folder (usually C:\Documents and Settings\All Users\Application Data on winXP). It seems to work fine when invoked in the Form_Load method.</p> ]]></description>
<pubDate>Mon, 15 Dec 2008 11:59:07 GMT</pubDate>
<guid>http://snipplr.com/view/10502/set-the-directory-connection-string-for-an-sql-server-database-connection/</guid>
</item>
</channel>
</rss>