<configuration>
......
<system.data>
<DbProviderFactories>
<add name="SQLite Data Provider"
invariant="System.Data.SQLite"
description=".Net Framework Data Provider for SQLite"
type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
</DbProviderFactories>
</system.data>
<connectionStrings>
<add name="MainDB" providerName="System.Data.SQLite" connectionString="Data Source=data/main.db;Version=3"/>
</connectionStrings>
......
</configuration>
static class DbConnection
{
public static IDbConnection Create()
{
ConnectionStringSettings mainDbConnectionStringSettings = ConfigurationManager.ConnectionStrings["MainDB"];
DbProviderFactory factory = DbProviderFactories.GetFactory(mainDbConnectionStringSettings.ProviderName);
IDbConnection dbConnection = factory.CreateConnection();
dbConnection.ConnectionString = mainDbConnectionStringSettings.ConnectionString;
dbConnection.Open();
return dbConnection;
}
public static void Destroy(IDbConnection dbConnection)
{
dbConnection.Dispose();
}
}
И сразу спрошу - откуда взят логин? Это Windows-логин или логин в SQL Server? Если Windows-типа, то винда в домене или вы дома сидите?