c# - MySql 查询没有返回预期的数据

标签 c# mysql

"select * from clinic_app_database.appointment_details1 where ' " + 
 this.txtCView.SelectedItem + " ' = ' " + 
 this.txt_givenID.Text + "';";

我使用 mysql workbench .. C# 平台编写了这个查询

我一次插入组合框值和文本框值,但没有得到答案。

select * from tablename where (here am using combobox for value) = textbox;

如果有人知道,请告诉我正确的语法

提前致谢

最佳答案

您正在将 txtCView.SelectedItem 传递给查询,而不是传递它的值。
此外,您在值的开头和结尾添加的额外空格正在修改字符串。
试试这个:

"select * from clinic_app_database.appointment_details1 where '" + 
 this.txtCView.SelectedItem.Value + "' = '" + this.txt_givenID.Text + "';";

关于c# - MySql 查询没有返回预期的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25865992/

相关文章:

c# - 以已知类作为分组键的 GroupBy

c# - 在 .NET 中开发一个在后台运行的程序?

c# - 这个方法是异步的吗?

c# - @Html.EditorFor(m => m) MVC 中的 lambda 语法

mysql - MySQL中可以使用命令更改数据库的默认路径吗?

php - php 从 mySql 获取行从某个点降序

c# - Visual Studio Code : How to see all classes inherited from a base class or interface?

mysql - mySQL 中的“紧凑”SELECT 结果

mysql - 以十进制形式返回 SQL

php - 如何通过 PHP 处理 Sedna