无法将类型'system.data.datatable'隐式转换为'int',我该如何纠正? [英] Cannot implicitly convert type 'system.data.datatable' to 'int' how do I rectify it?
问题描述
Cannot implicitly convert type ''System.Data.DataTable'' to ''int''
我正在3层架构中进行操作.
我尝试过的事情:
I''m doing it in 3 tier architecture.
What I have tried:
public int Doctor_appointment(query qr)
{
cmd.Parameters.AddWithValue("@Name", qr.Name);
cmd.Parameters.AddWithValue("@Place", qr.Place);
cmd.Parameters.AddWithValue("@Date", qr.Date);
cmd.Parameters.AddWithValue("@Time", qr.Time);
DataTable r = extablestore("Doctor_Page_appointment", cmd);
return r ;
}
推荐答案
查看方法定义:
Look at the method definition:
public int Doctor_appointment(query qr)
现在看看您要返回的内容:
Now look at what you are trying to return:
DataTable r = extablestore("Doctor_Page_appointment", cmd);
return r ;
数据表可能包含许多整数,并且具有一些返回整数值的属性和方法:系统不知道您要返回哪个值,也无法猜测.
可能您想返回数据表,因此将您的方法定义更改为:
A datatable may contains many integers, and has several properties and methods that return integer values: the system does not know which value you want to return and cannot guess.
Probably, you want to return the datatable, so change your method definition to:
public DataTable Doctor_appointment(query qr)
但是,如果不了解系统的其余部分,我们就无法告诉-因此请看一下如何使用该方法并做出决定.
But without intimate knowledge of the rest of your system we can''t tell - so look at how you are going to use the method and decide.
这篇关于无法将类型'system.data.datatable'隐式转换为'int',我该如何纠正?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!