The LJCDataAccess.DataAccess class is capable of connecting using the SQL Server data provider, OLEDB driver, ODBC driver or MySQL data provider.
using LJCDataAccess; using System.Data.Common; // Create DataAccess object. private static DataAccess CreateDataAccess() { // Create Data Configuration values. var connectionBuilder = new DbConnectionStringBuilder() { { "Data Source", "DataServerName" }, { "Initial Catalog", "DatabaseName" }, { "Integrated Security", "True" } // { "User Id", "UserID" }, // { "Password", "Password" } }; var connectionString = connectionBuilder.ConnectionString; var providerName = "System.Data.SqlClient"; // Create DataAccess object. var retValue = new DataAccess(connectionString, providerName); return retValue; }
var connectionBuilder = new DbConnectionStringBuilder() { { "server", "DataServerName" }, { "database", "DatabaseName" } { "UserId", "UserID" }, { "Password", "Password" } }; var connectionString = connectionBuilder.ConnectionString; var providerName = "MySql.Data.MySqlClient";
var connectionBuilder = new DbConnectionStringBuilder() { { "Provider", "SQLOLEDB" }, { "Data Source", "DataServerName" }, { "Initial Catalog", "DatabaseName" }, // { "User Id", "UserID" }, // { "Password", "Password" } }; var connectionString = connectionBuilder.ConnectionString; var providerName = "SQLOLEDB";
var connectionBuilder = new DbConnectionStringBuilder() { { "Driver", "SQL Native Client" }, { "Server", "DataServerName" }, { "Database", "DatabaseName" }, { "uid", "UserID" }, { "pwd", "Password" } }; var connectionString = connectionBuilder.ConnectionString; var providerName = "MSDASQL.1";
var connectionBuilder = new DbConnectionStringBuilder() { { "Provider", "Microsoft.ACE.OLEDB.12.0" }, { "Data Source", "C:\File.accdb" }, { "Persist Security Info", "False" }, { "Jet OLEDB:Database Password", "Password" } }; var connectionString = connectionBuilder.ConnectionString; var providerName = "Microsoft.Jet.OLEDB.4.0";
var connectionBuilder = new DbConnectionStringBuilder() { { "Data Source", "C:\File.xlsx" }, { "Extended Properties", "Excel 12.0" }, { "HDR", "YES" } }; var connectionString = connectionBuilder.ConnectionString;
var connectionBuilder = new DbConnectionStringBuilder() { { "Data Source", "C:\File.xls" }, { "Extended Properties", "Excel 8.0" }, { "HDR", "YES" } }; var connectionString = connectionBuilder.ConnectionString;
var connectionBuilder = new DbConnectionStringBuilder() { { "Data Source", "ORCL" }, { "Integrated Security", "yes" } // { "User Id", "UserID" }, // { "Password", "Password" } }; var connectionString = connectionBuilder.ConnectionString;
var connectionBuilder = new DbConnectionStringBuilder() { { "Provider", "Microsoft.ACE.OLEDB.12.0" }, { "Data Source", "C:\File.txt" }, { "Extended Properties", "text" }, { "HDR", "yes" }, { "FMT", "Delimited" } };