Advertisement
Guest User

Untitled

a guest
May 16th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using MySql.Data.MySqlClient;
  7.  
  8. namespace DBConnectionTest
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. string connectionString = "datasource=localhost;port=3306;username=root;password=ece426spring2017";
  15. MySqlConnection connection = new MySqlConnection(connectionString);
  16. MySqlDataAdapter myDataAdapter = new MySqlDataAdapter();
  17. myDataAdapter.SelectCommand = new MySqlCommand("Select * from sakila.actor ;", connection);
  18. MySqlCommandBuilder cb = new MySqlCommandBuilder(myDataAdapter);
  19. connection.Open();
  20. Console.WriteLine("connected");
  21. connection.Close();
  22.  
  23.  
  24. }
  25. }
  26. }
  27.  
  28.  
  29. //you gotta download sql connector also https://dev.mysql.com/downloads/connector/net/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement