Bonjour à tous, je souhaiterais de l'aide afin de créer un programme en C++, j'ai commencé sa création avec Windows Form, le but de ce programme est de créer une requête SQL à partir d'informations que l'utilisateur met dans deux champs de texte ( richTextBox2 et TextBox1 ) et la requête SQL doit s'afficher dans un autre champ de texte : richTextBox1.
#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <string>
namespace SQL_Gossip {
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 std;
/// <summary>
/// Description résumée de Form1
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: ajoutez ici le code du constructeur
//
}
protected:
/// <summary>
/// Nettoyage des ressources utilisées.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::RichTextBox^ richTextBox1;
protected:
private: System::Windows::Forms::RichTextBox^ richTextBox2;
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::LinkLabel^ linkLabel1;
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::Label^ label3;
private:
/// <summary>
/// Variable nécessaire au concepteur.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Méthode requise pour la prise en charge du concepteur - ne modifiez pas
/// le contenu de cette méthode avec l'éditeur de code.
/// </summary>
void InitializeComponent(void)
{
this->richTextBox1 = (gcnew System::Windows::Forms::RichTextBox());
this->richTextBox2 = (gcnew System::Windows::Forms::RichTextBox());
this->button1 = (gcnew System::Windows::Forms::Button());
this->button2 = (gcnew System::Windows::Forms::Button());
this->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->linkLabel1 = (gcnew System::Windows::Forms::LinkLabel());
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->label3 = (gcnew System::Windows::Forms::Label());
this->SuspendLayout();
//
// richTextBox1
//
this->richTextBox1->Location = System::Drawing::Point(42, 244);
this->richTextBox1->Name = L"richTextBox1";
this->richTextBox1->Size = System::Drawing::Size(531, 294);
this->richTextBox1->TabIndex = 0;
this->richTextBox1->Text = L""; //Pas touche
//
// richTextBox2
//
this->richTextBox2->Location = System::Drawing::Point(42, 70);
this->richTextBox2->Name = L"richTextBox2";
this->richTextBox2->Size = System::Drawing::Size(531, 96);
this->richTextBox2->TabIndex = 1;
this->richTextBox2->Text = L"";
//
// button1
//
this->button1->Location = System::Drawing::Point(440, 172);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(133, 23);
this->button1->TabIndex = 2;
this->button1->Text = L"Créer la requête SQL.";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// button2
//
this->button2->Location = System::Drawing::Point(440, 544);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(133, 23);
this->button2->TabIndex = 3;
this->button2->Text = L"Copier la requête.";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(12, 11);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(89, 13);
this->label1->TabIndex = 4;
this->label1->Text = L"ID de la créature.";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(12, 228);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(75, 13);
this->label2->TabIndex = 5;
this->label2->Text = L"Requête SQL.";
//
// linkLabel1
//
this->linkLabel1->AutoSize = true;
this->linkLabel1->Location = System::Drawing::Point(437, 9);
this->linkLabel1->Name = L"linkLabel1";
this->linkLabel1->Size = System::Drawing::Size(157, 13);
this->linkLabel1->TabIndex = 6;
this->linkLabel1->TabStop = true;
this->linkLabel1->Text = L"Créer pour le serveur : Achéron.";
this->linkLabel1->LinkClicked += gcnew System::Windows::Forms::LinkLabelLinkClickedEventHandler(this, &Form1::linkLabel1_LinkClicked);
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(12, 27);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(100, 20);
this->textBox1->TabIndex = 7;
this->textBox1->Text = L"";
//
// label3
//
this->label3->AutoSize = true;
this->label3->Location = System::Drawing::Point(15, 54);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(84, 13);
this->label3->TabIndex = 8;
this->label3->Text = L"Texte à afficher.";
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(609, 582);
this->Controls->Add(this->label3);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->linkLabel1);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->button2);
this->Controls->Add(this->button1);
this->Controls->Add(this->richTextBox2);
this->Controls->Add(this->richTextBox1);
this->Name = L"Form1";
this->Text = L"SQL Créer un gossip.";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
//
}
private: System::Void linkLabel1_LinkClicked(System::Object^ sender, System::Windows::Forms::LinkLabelLinkClickedEventArgs^ e)
{
//
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
richTextBox1->Text = ("UPDATE 'creature_template' SET 'npc_flags'=1 WHERE 'entry'='%s'", textBox1->Text);
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e)
{
}
};
}
Mais lorsque j'entre une valeur dans le champ de texte (textBox1), il s'affiche dans le champs de texte final (richTextBox) : "la_valeur_entrée_dans_le_champ_de_texte" au lieu de "UPDATE 'creature_template' SET 'npc_flags'=1 WHERE 'entry'='la_valeur_entrée_dans_le_champ_de_texte'"
Afficher la suite