Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Function Import

Posted on 2011-09-05
11
Medium Priority
?
308 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 64

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
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!

 
LVL 3

Author Comment

by:Kevin Robinson
ID: 36484398
Attached
0
 
LVL 64

Expert Comment

by:Fernando Soto
ID: 36484401
Attached? What is Attached?
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 64

Accepted Solution

by:
Fernando Soto earned 1000 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 1000 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

916 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