SHARE
TWEET

Untitled

a guest Oct 3rd, 2017 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. System.TimeoutException: 'Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.'
  2.    
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using MySql.Data;
  8.  
  9. namespace ConsoleApplication1
  10. {
  11. class Program
  12. {
  13. static void Main(string[] args)
  14. {
  15. string serverIp = "hostname/hostip"; //ip of database
  16. string username = "username"; //database user that i created with mysql database wizard whic has all permissions
  17. string password = "userpassword"; //user password
  18. string databaseName = "databasename"; //database name
  19.  
  20. string createTableQuery = string.Format(@"CREATE TABLE `{0}` (
  21. `sid` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
  22. `name` varchar(120) NOT NULL DEFAULT '',
  23. `title` varchar(120) NOT NULL DEFAULT '',
  24. `description` text NOT NULL,
  25. `optionscode` text NOT NULL,
  26. `value` text NOT NULL,
  27. `disporder` smallint(5) unsigned NOT NULL DEFAULT '0',
  28. `gid` smallint(5) unsigned NOT NULL DEFAULT '0',
  29. `isdefault` tinyint(1) NOT NULL DEFAULT '0',
  30. PRIMARY KEY (`sid`),
  31. KEY `gid` (`gid`))
  32. ENGINE = MyISAM AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8;", "TestTable1");
  33.  
  34. string dbConnectionString = string.Format("server={0};uid={1};pwd={2};database={3};", serverIp, username, password, databaseName);
  35.  
  36. try
  37. {
  38. MySql.Data.MySqlClient.MySqlConnection conn = new MySql.Data.MySqlClient.MySqlConnection(dbConnectionString);
  39. conn.Open();
  40.  
  41. var cmd = new MySql.Data.MySqlClient.MySqlCommand(createTableQuery, conn);
  42. cmd.ExecuteNonQuery();
  43.  
  44. Console.WriteLine("done");
  45. }
  46. catch (Exception)
  47. {
  48. Console.WriteLine("nope");
  49. throw;
  50. }
  51. Console.ReadKey();
  52. }
  53.  
  54. }
  55. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top