Create a Connection String

Within your web.config file, you can add a connectionStrings element (under the configuration element). Below are examples for various data stores.

PostgreSQL
    <connectionStrings>
        <add name="MyDatabase"
            connectionString="Server=127.0.0.1;Port=5432;User Id=appuser;Password=apppwd;Database=appdatabase"
            providerName="Npgsql"/>
    </connectionStrings>

MySQL
    <connectionStrings>
        <add name="MyDatabase"
            connectionString="Server=127.0.0.1;Database=appdatabase;Uid=appuser;Pwd=apppwd;"
            providerName="MySql.Data.MySqlClient"/>
    </connectionStrings>

SQL Server
    <connectionStrings>
        <add name="MyDatabase"
            connectionString="Server=127.0.0.1;Database=appdatabase;User ID=appuser;Password=apppwd;Trusted_Connection=False;"
            providerName="System.Data.SqlClient"/>
    </connectionStrings>

SQLite
    <connectionStrings>
        <add name="MyDatabase"
            connectionString="Data Source=|DataDirectory|database.s3db;Version=3;"
            providerName="System.Data.SQLite"/>
    </connectionStrings>

ODBC
    <connectionStrings>
        <add name="MyDatabase"
            connectionString="DSN=myDsn;Uid=appuser;Pwd=;"
            providerName="System.Data.Odbc"/>
    </connectionStrings>

TIP: If your password is actually "apppwd", you deserve to be hacked. :)

<<

Last edited Oct 19, 2011 at 2:08 AM by danielsummers, version 2

Comments

No comments yet.