Solved

Function Import

Posted on 2011-09-05
11
303 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
Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

756 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