Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. public void Export(string sql)
  2. {
  3. //Server - the host of the sql server
  4. //Database - an intial catalog/database on which it should do the queries. if needed change it to your database name
  5. //Port - the port of the sql server, it might not be needed always.
  6. var Driver = new NHibernate.Driver.MySqlDataDriver();
  7. var conn = Driver.CreateConnection();
  8. conn.ConnectionString =
  9. "Server=" + Host +
  10. ";Database=mysql" +
  11. ";Username='" + Username +
  12. "';Password='" + Password +
  13. "';Port=" + Port + ";";
  14. conn.Open();
  15.  
  16. var command = Driver.CreateCommand();
  17. command.CommandText = sql;
  18. command.Connection = conn;
  19. command.ExecuteNonQuery();
  20.  
  21. command.Dispose();
  22. conn.Close();
  23. conn.Dispose();
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement