using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace DynamicSimulator_v2 { public partial class SchemaName : Form { private string data; public SchemaName() { InitializeComponent(); } private void btnCancel_Click(object sender, EventArgs e) { this.Hide(); } private void btnOK_Click(object sender, EventArgs e) { data=txtDB.Text; this.Hide(); } public string getData() { return data; } } }
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using MySql.Data; using MySql.Data.MySqlClient; namespace DynamicSimulator_v2 { public partial class frmMain : Form { public frmMain() { InitializeComponent(); } private void btnExit_Click(object sender, EventArgs e) { Application.Exit(); } private void btnNew_Click(object sender, EventArgs e) { SchemaName schemaForm = new SchemaName(); schemaForm.Show(); if () //I'm stuck at this part. I would like to do something like this // if ( schemaForm.Show() == System.Windows.Forms.Button btnOK ) { MessageBox.Show(schemaForm.getData()); } /* string connStr = "datasource=localhost;port=3306;username=root;password=root;"; MySqlConnection conn = new MySqlConnection(connStr); try { conn.Open(); MySqlCommand cmdDatabase = new MySqlCommand("CREATE SCHEMA @schema; ", conn); cmdDatabase.Parameters.AddWithValue("@schema", data.getSchema()); MySqlDataReader myReader; myReader = cmdDatabase.ExecuteReader(); myReader.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } conn.Close(); }*/ } } }
SchemaName schemaForm = new SchemaName(); if (schemaForm.ShowDialog() == DialogResult.OK) { ... }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)