大家好,我的查询如下所示,sql
其中给出了结果,这是我的查询
SELECT Technology,TechDescription, Technology.TechID, COUNT(Question) AS
'Totalposts' FROM Technology LEFT JOIN Question ON Question.TechID = Technology.TechID GROUP BY Technology.TechID, Technology,TechDescription
我只是将其写入存储过程,如下所示
USE [newForumDB]
GO
/****** Object: StoredProcedure [dbo].[selectTechQuestions] Script Date: 01/24/2013 15:06:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create PROCEDURE [dbo].[selectTechQuestions]
As
SET FMTONLY OFF
Begin
SELECT Technology,TechDescription, Technology.TechID, COUNT(Question) AS
'Totalposts'
FROM Technology
LEFT JOIN Questions
ON Questions.TechID = Technologies.TechID
GROUP BY Technologies.TechID, Technology,TechDescription
End
并将其添加到我的模型中,并尝试为该过程添加一个功能,但我收到了消息,The selected stored procedure returns no columns
有人可以帮助我
根据Habib
要求,我尝试了两种方式,即
1) writing the query in a string and filled the DataSet using SqlCommand and SqlDataAdapter which works fine
2) SqlCommand cmd = new SqlCommand();
cmd.CommandText = "selectTechQuestions";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = con;
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataSet ds = new DataSet();
da.Fill(ds);
第二个给了我错误{"Invalid object name 'Questions'."}