-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
worked on controller, started on mysql controller
- Loading branch information
Jeremy Mill
committed
Nov 3, 2015
1 parent
d491318
commit 6fada2e
Showing
4 changed files
with
110 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Web; | ||
using MySql.Data.MySqlClient; | ||
|
||
namespace TeamDBAwesome.SqlService | ||
{ | ||
public class MySqlService | ||
{ | ||
private MySqlConnection SqlConn; | ||
private string server, database, uid, password; | ||
|
||
//constructor | ||
/// <summary> | ||
/// Creates an instance of the MySqlService | ||
/// </summary> | ||
public MySqlService() | ||
{ | ||
Init_Connection(); | ||
} | ||
|
||
/// <summary> | ||
/// creates the actual connection, keeping things private | ||
/// </summary> | ||
private void Init_Connection() | ||
{ | ||
server = "localhost"; | ||
database = "chinook"; | ||
uid = "root"; | ||
//changeme | ||
password = "a_password"; | ||
|
||
string connectionString = "SERVER=" + server + ";" + "DATABASE=" + database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";"; | ||
|
||
SqlConn = new MySqlConnection(connectionString); | ||
} | ||
|
||
/// <summary> | ||
/// opens a connection to the DB | ||
/// </summary> | ||
/// <returns>a bool representing the success or failure</returns> | ||
private bool OpenConnection() | ||
{ | ||
try | ||
{ | ||
SqlConn.Open(); | ||
return true; | ||
} | ||
catch (Exception e) | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// closes a connection to the DB | ||
/// </summary> | ||
/// <returns>bool for success or failure</returns> | ||
private bool CloseConnection() | ||
{ | ||
try | ||
{ | ||
SqlConn.Close(); | ||
return true; | ||
} | ||
catch (Exception e) | ||
{ | ||
return false; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters