MySQL Question

Error System.ArgumentException Keyword not supported. c++

i tried to make program for connecting to my MySQL database and change information in it. But when i try to insert some command i get error.

Unhandled exception of type "System.ArgumentException" in System.Data.dll
Additional Information: Keyword not supported.


namespace Pro4 {

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>
/// Сводка для MyForm
/// </summary>
public ref class MyForm : public System::Windows::Forms::Form
{
public:
MyForm(void)
{
InitializeComponent();
//
//TODO: добавьте код конструктора
//
}

protected:
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
~MyForm()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::TextBox^ txtQuery;
protected:

protected:
private: System::Windows::Forms::Button^ button1;

private:
/// <summary>
/// Требуется переменная конструктора.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Обязательный метод для поддержки конструктора - не изменяйте
/// содержимое данного метода при помощи редактора кода.
/// </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(823, 269);
this->txtQuery->TabIndex = 0;
//
// button1
//
this->button1->Location = System::Drawing::Point(715, 287);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(120, 40);
this->button1->TabIndex = 1;
this->button1->Text = L"Run";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this,
&MyForm::button1_Click);
//
// MyForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(8, 16);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(847, 531);
this->Controls->Add(this->button1);
this->Controls->Add(this->txtQuery);
this->Name = L"MyForm";
this->Text = L"MyForm";
this->ResumeLayout(false);
this->PerformLayout();

}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
String^ SQLQuery = txtQuery->Text;
String^ connectionInfo = "datasourse=localhost;port=3307;username=root;password=1qa2ws3ed;database=labeng";
MySqlConnection^ conn= gcnew MySqlConnection(connectionInfo);
MySqlCommand^ connCmd = gcnew MySqlCommand(SQLQuery, conn);
MySqlDataReader^ dataReader;

try{
conn->Open();
dataReader = connCmd->ExecuteReader();
//MessageBox::Show("Command is done");
}
catch (Exception^ex){
MessageBox::Show(ex->Message);
}

}
};
}


Please, don't be strict, it's new for me.

Answer

Standard warning: While it's certainly possible to write the main body of your application in C++/CLI, or even write the GUI in C++/CLI using WinForms, it is not recommended. C++/CLI is intended for interop scenarios: where C# or other .Net code needs to interface with unmanaged C++, C++/CLI can provide the translation between the two. For primary development, it is recommended to use C# with either WinForms or WPF if you want managed code, or C++ with MFC if you want unmanaged.


That said,

String^ connectionInfo = "datasourse=localhost;port=3307;username=root;password=1qa2ws3ed;database=labeng";

According to the documentation, the connection string is supposed to contain server=localhost, not datasource=localhost.