Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- namespace Youtube {
- using namespace System;
- using namespace System::ComponentModel;
- using namespace System::Collections;
- using namespace System::Windows::Forms;
- using namespace System::Data;
- using namespace System::Drawing;
- using namespace MySql::Data::MySqlClient;
- /// <summary>
- /// Summary for Form1
- /// </summary>
- public ref class Form1 : public System::Windows::Forms::Form
- {
- public:
- Form1(void)
- {
- InitializeComponent();
- //
- //TODO: Add the constructor code here
- //
- }
- protected:
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- ~Form1()
- {
- if (components)
- {
- delete components;
- }
- }
- private: System::Windows::Forms::TextBox^ txtQuery;
- protected:
- private: System::Windows::Forms::Button^ button1;
- private:
- /// <summary>
- /// Required designer variable.
- /// </summary>
- System::ComponentModel::Container ^components;
- #pragma region Windows Form Designer generated code
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- void InitializeComponent(void)
- {
- this->txtQuery = (gcnew System::Windows::Forms::TextBox());
- this->button1 = (gcnew System::Windows::Forms::Button());
- this->SuspendLayout();
- //
- // txtQuery
- //
- this->txtQuery->Location = System::Drawing::Point(12, 12);
- this->txtQuery->Multiline = true;
- this->txtQuery->Name = L"txtQuery";
- this->txtQuery->Size = System::Drawing::Size(841, 192);
- this->txtQuery->TabIndex = 0;
- //
- // button1
- //
- this->button1->Location = System::Drawing::Point(741, 210);
- this->button1->Name = L"button1";
- this->button1->Size = System::Drawing::Size(112, 49);
- this->button1->TabIndex = 1;
- this->button1->Text = L"Run";
- this->button1->UseVisualStyleBackColor = true;
- this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
- //
- // Form1
- //
- this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
- this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
- this->ClientSize = System::Drawing::Size(865, 586);
- this->Controls->Add(this->button1);
- this->Controls->Add(this->txtQuery);
- this->Name = L"Form1";
- this->Text = L"Form1";
- this->ResumeLayout(false);
- this->PerformLayout();
- }
- #pragma endregion
- private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
- String^ SQLQuery = txtQuery->Text;
- String^ connectionInfo = "datasource=localhost;port=3306;username=root;password=admin;database=programmers";
- MySqlConnection^ conn = gcnew MySqlConnection(connectionInfo);
- MySqlCommand^ connCmd = gcnew MySqlCommand(SQLQuery, conn);
- MySqlDataReader^ dataReader;
- try{
- conn->Open();
- dataReader=connCmd->ExecuteReader();
- MessageBox::Show("Command Performed");
- }catch(Exception^ex){
- MessageBox::Show(ex->Message);
- }
- }
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement