我收到我不明白的错误。我有一个表单,当我按下添加按钮时,必须添加新行。它必须检查comboBox cb_Character和comboBox cb_Talents中的值。当我测试它时,我得到了错误。数据对于列太长,但是当我在Mysql中尝试时,我能够做到。怎么了?
private void btn_addTalent_Click(object sender, RoutedEventArgs e)
{
string constring = "datasource= localhost; port=3306; username=root; password=Lorena89;";
string Query = "SET foreign_key_checks = 0; INSERT INTO dark_heresy.learned_talents (Character_Name, Talent_Name) VALUES ('" + cb_Character + "','" + cb_Talents + "'); SET foreign_key_checks = 1; ";
MySqlConnection conDataBase = new MySqlConnection(constring);
MySqlCommand cmdDatabase = new MySqlCommand(Query, conDataBase);
MySqlDataReader myReader;
try
{
conDataBase.Open();
myReader = cmdDatabase.ExecuteReader();
MessageBox.Show("Added Talent to Character");
while (myReader.Read())
{
}
}
catch (Exception ex)
{
MessageBox.Show("Error: \r\n" + ex);
}
}
最佳答案
我发现了错误,我错过了.Text
('" + cb_Character.Text + "','" + cb_Talents.Text + "');
关于c# - WPF Mysql数据对于列而言太长,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27219488/