Solved

Function Import

Posted on 2011-09-05
11
304 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

Independent Software Vendors: 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

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.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

752 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