Can not insert data from Windows Form Application into MySql database from Visual Studio 2017 in C++

  • Thread starter Thread starter Sazzad Saju
  • Start date Start date
S

Sazzad Saju

Guest
Sir, I want to share my problem with you to find the proper solution for my Project. Sir, I'm in the last step in my project where I had to insert data from Windows Form Application to MySql Database 8.0. I used language c++ in this project and My Visual Studio is the latest 2017 version. Everything worked properly but at the time of the application running, when I insert data from the form it says the query is error, where it shouldn't because I did everything according to a video tutorial, where the tutor did exact same code in vs10, which did not worked for me. Now how I supposed to code for inserting data from the form to mysql database. Also mentionable that, in the query if I directly insert data it works which I made comment line in the code. But all I want is to insert data from the Form not by the coding. Sir, how do i do that: here is the error and data table in the picture I share with you and here is the code for save button: (I couldn't attached the image, it says can not contain image or links , the error message was:<you have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near " at line 1>)


private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e) {
String^ constring = L"datasource= 127.0.0.1; port= 3306;username=root;password=12712";
MySqlConnection^ conDataBase = gcnew MySqlConnection(constring);
MySqlCommand^ cmdDataBase = gcnew MySqlCommand("INSERT INTO `university`.`student` (`id`,`name`,`password`) values('"+this->id_txt->Text+"','"+this->name_txt->Text+"','"+this->password_txt->Text+"' ;", conDataBase);
//MySqlCommand^ cmdDataBase = gcnew MySqlCommand("INSERT INTO `university`.`student` (`id`, `name`, `password`) VALUES ('7', 'ah', '77'); ", conDataBase);


Continue reading...
 
Back
Top