私は自分のMySQLデータベースに接続して情報を変更しようとしました。しかし、私はいくつかのコマンドを挿入しようとするとエラーが発生します。エラーSystem.ArgumentExceptionキーワードがサポートされていません。 C++
System.Data.dllの "System.ArgumentException"型の未処理例外 追加情報:キーワードはサポートされていません。
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);
}
}
};
}
私には厳しいものではありません。
今後、すべてのGUIコードを質問にダンプしないでください。例外をスローしている行は正確に記述してください。私たちに検索や推測をさせてはいけません。あなたのコード全体を検索して、面白いビットを見つけたり、どのラインが例外を出すのかを推測してください。 –