Solved

Function Import

Posted on 2011-09-05
11
302 Views
Last Modified: 2012-05-12
I am trying to create a function import for a stored procedure.  

When I try to add the function import and click "Get Column information"  i get the response the stored procedure returns no columns.   It does not allow me to pass in any default values.
0
Comment
Question by:Kevin Robinson
  • 4
  • 3
  • 3
  • +1
11 Comments
 
LVL 15

Expert Comment

by:Minh Võ Công
ID: 36483258
Can you explain your question more detail ?
0
 
LVL 3

Author Comment

by:Kevin Robinson
ID: 36483345
Sorry I should have mentioned I am working with entity framework.

I have a stored procedure re (That I cannot modify)  which returns a query.  This query will not map to a specific entity so I need to create a complex type.  

In order to do this within visual studio I create a funciton import select complex type then click Get Colum information.  The problem is that because you cannot assign any values for running the stored procedure the design gives the error  "stored procedure returns no columns".
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 36484057
Hi VolunteerDevelopmentAgency;

To your statement, "The problem is that because you cannot assign any values for running the stored procedure the design gives the error  "stored procedure returns no columns".", For some reason the EF designer believes that the stored procedure is not returning any columns. Can you please post the Stored Procedure.

Thanks;
Fernando
 
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 3

Author Comment

by:Kevin Robinson
ID: 36484398
Attached
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 36484401
Attached? What is Attached?
0
 
LVL 3

Author Comment

by:Kevin Robinson
ID: 36484468
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 36484586
Unfortunately since you cannot modify the Stored Procedure, there is nothing you can do about it.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 36484591
If you could modify the Stored Procedure you would make sure that SET NOCOUNT ON was the first executable code.  This would allow your application to see the result sets.
0
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 250 total points
ID: 36484646
Hi VolunteerDevelopmentAgency;

First I am NOT a SQL Server Guru but looking at your SP it looks like to me that you are returning multiple result sets which are NOT supported in EF.

If you want to try a work around you can look at this article,  ADO.NET Entity framework advanced scenarios: Working with stored procedures that return multiple resultsets as well as downloading the ADO.NET Entity Framework Extensions.

Fernando
0
 
LVL 75

Assisted Solution

by:Anthony Perkins
Anthony Perkins earned 250 total points
ID: 36484993
You make a good point, there is one case when more than one resultset is returned (abbreviated below for clarity). So if EF has a problem with multiple resultsets, then that is going to be a problem.

ELSE IF LOWER(@ReportType) = 'details'
BEGIN
	IF @AllContacts = 0
	BEGIN
		SELECT *
		FROM OrganisationResults
		WHERE RowNumber 
			BETWEEN (@SelectPage - 1) * @PageSize + 1 
			AND @SelectPage * @PageSize
		ORDER BY
			[OrganisationName],
			[SiteName]
				
		-- Also return a count of the total number of pages
		SELECT CEILING(COUNT(*)/CAST(@PageSize AS float)) AS TotalPages
		FROM
			#MatchingOrganisations MO
			INNER JOIN tblOrganisations ORG ON MO.OrganisationID = ORG.OrganisationID
			INNER JOIN tblSites SIT ON ORG.OrganisationID = SIT.FKOrganisationID
		WHERE
			SIT.Deleted = 0
	END
	ELSE
	BEGIN
		-- Return the results 
		SELECT *
		FROM OrganisationResults
		WHERE RowNumber 
			BETWEEN (@SelectPage - 1) * @PageSize + 1 
			AND @SelectPage * @PageSize
		ORDER BY
			[OrganisationName],
			[SiteName],
			[Surname],
			[FirstName]
				
		-- Also return a count of the total number of pages
		SELECT CEILING(COUNT(*)/CAST(@PageSize AS float)) AS TotalPages
		FROM
			#MatchingOrganisations MO
			INNER JOIN tblOrganisations ORG ON MO.OrganisationID = ORG.OrganisationID
			INNER JOIN tblSites SIT ON ORG.OrganisationID = SIT.FKOrganisationID
			INNER JOIN tblSiteContacts SCN ON SIT.SiteID = SCN.FKSiteID
			INNER JOIN tblContacts CON ON SCN.FKContactID = CON.ContactID
		WHERE
			SIT.Deleted = 0 AND
			CON.Deleted = 0 AND
			CON.AcceptsEmails = 1
	END
END

Open in new window

0
 
LVL 3

Author Comment

by:Kevin Robinson
ID: 36565733
I will be working on this today.  Sorry for dealy
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question