C++ 将数据添加到现有的SQL列中
编辑: 随机搜索其他语言,如果有人需要,我会找到正确答案: “更新数据库_Name set Column='”+value+“,其中ID='“+value+”;” 我需要在列中插入数据,但在web上找不到有关该列的详细信息 代码是C++ 将数据添加到现有的SQL列中,c++,mysql,sql,C++,Mysql,Sql,编辑: 随机搜索其他语言,如果有人需要,我会找到正确答案: “更新数据库_Name set Column='”+value+“,其中ID='“+value+”;” 我需要在列中插入数据,但在web上找不到有关该列的详细信息 代码是 private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { if (this->listBox1->
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
if (this->listBox1->SelectedIndex!=-1)
{
String^ constring = L"datasource=localhost;port=3306;username=root;password=root;";
MySqlConnection^ conDataBase = gcnew MySqlConnection(constring);
MySqlCommand^ cmdDataBase =
gcnew MySqlCommand(insert into products_shop.productname where idProductName='"+this-listBox1->SelectedItem->ToString()+"' ('ProductX','ProductY') values('"+this->textBox2-Text+","+this->textBox3->Text+"');",conDataBase);
MySqlDataReader^ MyReader;
try
{
conDataBase->Open();
MyReader = cmdDataBase->ExecuteReader();
}
catch(Exception^ex)
{
MessageBox::Show(ex->Message);
}
}
else
{
MessageBox::Show(L"Select an item please");
}
}
insert into products_shop.productname where idProductName='"+this->listBox1-SelectedItem-ToString()+"' ('ProductX','ProductY') values('"+this->textBox2-Text+","+this->textBox3-Text+"');
这一行只是我的randm猜测,关于语法应该是怎样的,有什么帮助吗?或者如果它的工作方式有所不同。。
感谢您的帮助听起来您需要使用update而不是insert?如果没有任何类型,这是非常危险的错误代码。