Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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.'
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using MySql.Data;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- string serverIp = "hostname/hostip"; //ip of database
- string username = "username"; //database user that i created with mysql database wizard whic has all permissions
- string password = "userpassword"; //user password
- string databaseName = "databasename"; //database name
- string createTableQuery = string.Format(@"CREATE TABLE `{0}` (
- `sid` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
- `name` varchar(120) NOT NULL DEFAULT '',
- `title` varchar(120) NOT NULL DEFAULT '',
- `description` text NOT NULL,
- `optionscode` text NOT NULL,
- `value` text NOT NULL,
- `disporder` smallint(5) unsigned NOT NULL DEFAULT '0',
- `gid` smallint(5) unsigned NOT NULL DEFAULT '0',
- `isdefault` tinyint(1) NOT NULL DEFAULT '0',
- PRIMARY KEY (`sid`),
- KEY `gid` (`gid`))
- ENGINE = MyISAM AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8;", "TestTable1");
- string dbConnectionString = string.Format("server={0};uid={1};pwd={2};database={3};", serverIp, username, password, databaseName);
- try
- {
- MySql.Data.MySqlClient.MySqlConnection conn = new MySql.Data.MySqlClient.MySqlConnection(dbConnectionString);
- conn.Open();
- var cmd = new MySql.Data.MySqlClient.MySqlCommand(createTableQuery, conn);
- cmd.ExecuteNonQuery();
- Console.WriteLine("done");
- }
- catch (Exception)
- {
- Console.WriteLine("nope");
- throw;
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement