Solved

Function Import

Posted on 2011-09-05
11
294 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 62

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
 
LVL 3

Author Comment

by:Kevin Robinson
ID: 36484398
Attached
0
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 36484401
Attached? What is Attached?
0
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 
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 62

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

705 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now