mirror of
https://github.com/stokebob/bnhtrade.git
synced 2026-03-19 22:47:15 +00:00
Add project files.
This commit is contained in:
40
bnhtrade Database Client/SQL Connection.cs
Normal file
40
bnhtrade Database Client/SQL Connection.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Data.SqlClient;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace DatabaseConnection
|
||||
{
|
||||
//[ComVisible(true)]
|
||||
//[Guid("8bebe939-7a73-4ba3-877b-50cd2a7e4586")]
|
||||
//[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
|
||||
public interface bnhtradeDbInterface
|
||||
{
|
||||
SqlConnection Connection(string DataSource, string InitialCatalog, string UserId, string Password, bool PersistSecurityInfo = true, bool MultipleActiveResultSets = true);
|
||||
}
|
||||
|
||||
//[ComVisible(true)]
|
||||
//[Guid("b0e29c9e-d353-4d3a-83dd-5278b520af54")]
|
||||
//[ClassInterface(ClassInterfaceType.None)]
|
||||
////[ProgId("MyNameSpace.Criteria")]
|
||||
public class bnhtradeDb : bnhtradeDbInterface
|
||||
{
|
||||
public SqlConnection Connection(string DataSource, string InitialCatalog, string UserId, string Password, bool PersistSecurityInfo = true, bool MultipleActiveResultSets = true)
|
||||
{
|
||||
if (InitialCatalog == "" || DataSource == "" || UserId == "" || Password == "")
|
||||
{
|
||||
throw new Exception("Insuficent info supplied for sql connection string");
|
||||
}
|
||||
string connString =
|
||||
"Data Source=" + DataSource + ";Initial Catalog=" + InitialCatalog + ";Persist Security Info=" + PersistSecurityInfo.ToString() + ";" +
|
||||
"User ID=" + UserId + ";Password=" + Password + ";MultipleActiveResultSets=" + MultipleActiveResultSets.ToString() + "";
|
||||
|
||||
SqlConnection sqlConn = new SqlConnection(connString);
|
||||
|
||||
return sqlConn;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user