Created
February 14, 2017 23:52
-
-
Save ilopez/4f2862d89f1e789e749b2eda52d81a71 to your computer and use it in GitHub Desktop.
Test Firebird and MySQL Connection
This file contains hidden or 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
using System; | |
using System.Collections.Generic; | |
using System.Data; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using Dapper; | |
using FirebirdSql.Data.FirebirdClient; | |
using MySql.Data.MySqlClient; | |
namespace ConsoleApplication1 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
String host = "localhost"; | |
int port = 3305; | |
String dbname = "fishbowl_demo"; | |
String user = "gone"; | |
String pass = "fishing"; | |
IDbConnection db = null; | |
if (port == 3050 || dbname.EndsWith(".fdb")) | |
{ | |
// Firebird | |
FbConnectionStringBuilder csb = new FbConnectionStringBuilder(); | |
csb.DataSource = host; | |
csb.Port = port; | |
csb.Database = dbname; | |
csb.UserID = user; | |
csb.Password = pass; | |
db = new FbConnection(csb.ToString()); | |
} | |
else | |
{ | |
MySqlConnectionStringBuilder csb = new MySqlConnectionStringBuilder(); | |
csb.Database = dbname; | |
csb.Server = host; | |
csb.Port = Convert.ToUInt32(port); | |
csb.UserID = user; | |
csb.Password = pass; | |
db = new MySqlConnection(csb.ToString()); | |
// MySQL | |
} | |
db.Open(); | |
List<String> soNums = db.Query<String>("select num from so").ToList(); | |
Console.WriteLine(String.Join(",",soNums)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment