简体   繁体   English

如何使用C#获取mysql表中特定项目的计数

[英]How to get count of a particular item in mysql table using c#

I am tried to get count of a particular item from mysql table using c#.but i got nothing 我试图使用c#从mysql表中获取特定项目的计数,但我一无所获

My code 我的密码

string Batch = textBox8.Text;
string batchnumber = ("SELECT COUNT [Batch_No] FROM Orders where Batch_No='" + Batch + "'");

orders is my table and batch_no is the column and i want to get the count of particular batch number in the table.How can i do this? 我的表是orders,列是batch_no,我想获取表中特定批号的计数。我该怎么办?

Change COUNT [Batch_No] to COUNT(Batch_No) . COUNT [Batch_No]更改为COUNT(Batch_No) It will work. 它会工作。

Try this: 尝试这个:

string Batch = textBox8.Text;
string batchnumber = ("SELECT COUNT(Batch_No) FROM Orders WHERE Batch_No='" + Batch + "'");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在不使用C#中的for或foreach循环的情况下使用datatable从特定的mysql表中获取每个值? - How to get each value from a particular mysql table by using datatable without using a for or foreach loop in c#? 如何在c#中使用表格的html隐藏具有条件的特定li项 - How to hide particular li item with condition using html of table in c# 如何在 linq c# 中获取项目值和项目数 - How to get item value and item count in linq c# 如何使用 c# 获取有关 mysql 表的所有详细信息? - how to get all details about a mysql table using c#? 如何使用C#编码更改特定项目的Sitecore模板? - How to change sitecore template of particular item using c# coding? 使用 selenium c# 获取下拉项目数 - get dropdown item count using selenium c# 如何使用C#计算MySQL表中的列数? - How can I count the number of columns in a MySQL table using C#? 使用Selenium Driver C#从表中获取最后一项 - Get last item from a table using Selenium Driver C# 如何使用linq和C#中的实体框架从另一个表中获取对象中的项目列表? - how to get a list of item in object from another table using linq and entity framework in C#? 如何使用c#获取包含特定文件的目录列表 - How to get list of directories containing particular file using c#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM