Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.33 KB | None | 0 0
  1. using System;
  2. using Gtk;
  3. using System.Configuration;
  4. using System.IO;
  5. using System.Reflection;
  6. using MySql.Data.MySqlClient;
  7.  
  8. namespace EmployeeScreen
  9. {
  10.     class MainClass
  11.     {
  12.         private static string connectionString = string.Empty;
  13.     //  private static string databaseName = string.Empty;
  14.         private static MySql.Data.MySqlClient.MySqlConnection mysqlConn;
  15.         public static void Main (string[] args)
  16.         {
  17.             try {
  18.                 //connection string
  19.                 connectionString = ConfigurationSettings.AppSettings["mysqlConnectionString"].ToString();
  20.                 //select table
  21.                 mysqlConn = new MySql.Data.MySqlClient.MySqlConnection();
  22.                 mysqlConn.ConnectionString = connectionString;
  23.                 mysqlConn.Open();
  24.                
  25.                 //Create the sql script...
  26.                
  27.                 string createdbSql = "Select count(EmpID) from LocalDb.EmployeeDb";
  28.                
  29.                 using (MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand (createdbSql, mysqlConn)) {
  30.                     cmd.ExecuteNonQuery ();
  31.                     Console.WriteLine ("Employee Count");
  32.                 }
  33.                 //window
  34.                 Application.Init ();
  35.                 MainWindow win = new MainWindow ();
  36.                 win.Show ();
  37.                 Application.Run ();
  38.             } catch (Exception ex) {
  39.                 Console.WriteLine (ex.Message.ToString ());
  40.             } finally {
  41.                 if (mysqlConn != null) {
  42.                     mysqlConn.Close ();
  43.                     mysqlConn.Dispose ();
  44.                 }
  45.             }
  46.         }
  47.        
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement