.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Post New Web Links

No Return Type for a Stored Procedure in a Linq to SQL Data Layer

Posted By:      Posted Date: September 16, 2010    Points: 0   Category :ASP.Net
Hello. First, I don't know if this is the right forum section to post this in, but I couldn't fine a more suitable one. Feel free to move this if it's totally worng. I have a weird problem when using LINQ to SQL and Store Procedures with a return value... The problem is that when I drag my SP's onto the "Methods Pane" the property field "Return Type" is set to (None) and greyed out. And here's the most weird thing... I created a test SP yesterday wich returned SCOPE_IDENTITY() and it worked flawlessly. Dragged it onto the "Methods Pane", could play with the return type property (hence it was not greyed out) and everything was working out nice. I used a ISingleResult<T> and could fetch the .ReturnValue... Today I was going to contiune to create the rest of the SP's i needed with a return type but today when I drag my Store Procedures to my Methods Pane, I couldn't access the Return Type property... I even dragged the SAME procedure I used yesterday (wich then worked great) and now I can't get the dbml-layer to notice that there is a return value... I've tried to create new solutions, new Data Layers, used different databases/servers, but still the same problem... Don't really know if it's LINQ or something else that's causing this... This is how part of my SP wich I used yesterday to test looks

View Complete Post

More Related Resource Links

Return type of Linq to SQL Stored Procedures


Dear all,

I am using .net framework 3.5 and sql server 2008.

In my project coding, I want to call stored procedures in sql server 2008.

return value is the object list which references the entity.

But I have the questions.

If in the entity named as "order", is it matching the properties or created through entity constructor??

In my case, I have two properties and one constructor which match one property.

public class orders


orders ( string orderid)




public string orderid {get;set;}

public string orderno{get;set;}

Use a stored procedure to return data for algorithm



I am looking at using the time series algorithm to predict a products future.

However, I seem to have missed the obvious. How do I return a subset of a tables data as the input to the algorithm?

Can I specifiy a SP to use or do I specify the parameters within DMX?



Need Syntax To Make Results of LINQ Union Return Non-Generic Type



I have the below SQL which works just fine:

SELECT     Message, CreateDate, AccountId, AlertTypeId
FROM       dbo.Alerts
SELECT     TOP (100) PERCENT Status, CreateDate, AccountId,
                          (SELECT     10 AS Expr1) AS AlertTypeId
FROM         dbo.StatusUpdates
WHERE AccountId = PassedInParameter

I have been going about trying to convert the above into a LINQ method and am having problems with return types.
As the above SQL illustrates, I am querying two distinct LINQ tables - Alerts and StatusUpdates -
and then attempting to perform a Union on them. In order to do the union in LINQ, I have to have agreeing types. So, I
am using "var" to make the results of "alerts" and "updates" generic before the union.  

public IList GetStatusUpdatesAsAlertsByAccountId<T>(Int32 accountId)
            using (WorkbookDataContext dc = _conn.GetCont

The type 'System.Data.Linq.DataContext' is defined in an assembly that is not referenced. You must



This is frustrating, and I don't know how to solve it.

I have a strange problem. I am adding a LinqDatasource object, and set the context:

        protected void LinqDataSource_ContextCreating(object sender, LinqDataSourceContextEventArgs e)
            e.ObjectInstance = new KaruselaDataContext(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);

Then I get this error:
The type 'System.Data.Linq.DataContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Linq, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'.


On web.config I already have this:
<add assembly="System.Data.Linq, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>

NOTE: The datacontext is in a different project (DLL proect) where I added a refernce to System.Data.Linq.

is there another way adding a refernce to a web project? or only though teh web.config?


.NET Reflection: Dynamically Bind Your Data Layer to Stored Procedures and SQL Commands Using .NET M


One major inconvenience of using SQL stored procedures from code is having to match type information. You have to write long wrapper functions around the procedures just to expose the data types. In the .NET Framework, however, the reflection services of the System.Reflection namespace allow you to query rich metadata that describe data types. This article explains how to use reflection in .NET to end your stored procedure nightmares. The author creates four custom classes, including one that generates a SQLCommand object based on the metadata of a method. Using this library, you'll be on your way to automating the generation of stored procedures.

Atif Aziz

MSDN Magazine August 2002

Linq join fields for return data


  how would I join fields together?

           return (from c in storedb.Product_Categories

                         where c.Category_Name.Contains(searchText)
                         orderby c.Category_Name
                         select new {
                                    c.Category_Key && " ;" && c.Category_Name // HOW CAN I DO THIS.....

Trying to run a stored procedure from vb code with oracle data provider.



Here is my SP:

create or replace
 Open p_getuserssignon_recordset1 for
 SELECT Distinct(Userid), UserPassword, SecurityLevel, ActiveStatus
WHERE substr(UserId,1,2) <> vUid
Order By UserId;

I would like to run this SP from code and fill a gridview with the result. 

I am not sure how to go about this, as I have found several different examples, other than the one I  think I need.

I am using the oracle data provider and I have an input parameter (vUid, which will equal "zz").

First question. When filling a gridview with a result set from a stored procedure should the recordset OUT be defined as a REFCURSOR (like i did above)? 


Do you have example code as to how to execute the SP and fill a gridview?  I keep trying different variations of code i've found on the internet without any success other than getting more confused.

(I am using VS 2005, VB).

Thank you.



Entity Framework 4.0 Dynamic Data - stored procedure


I'm using Dynamic Data and have created a custom List.aspx page.  I simply want to populate the grid with a stored procedure.  I've seen some posts about doing this with a LinqDataSource but not an EntityDataSource.  Does someone have an example or a different way of doing this?  Thanks.

how to include a user defined table type as input for stored procedure

Hi ,  I have a user defined table type which i need to pass as input parameter to the stored procedure .How can i do that?

can a Workflow access a stored procedure and pass the parameters from the list data to the stored pr

The reason that I would like to consider this functionailty is because my table architecture is complicated and I do not want to modify my master table to accept all of this data where some of the data should be normalized into sub tables.  Has anyone see evidence of the stored-procedure parm approach?  Is this best accomplished through VS 2010 or can I do it through SPD? Thanks

SQL data type for HL7 message retaining carriage return and new line characters

Hi, What data type should be used for a column storing text as descripted in title? Please advise. I crrently have the message stored as text, but if I copy the message from studio management to a notepad, it will be come one big line of text instead.  

Stored Procedure Default Return Value

Tried searching and have not found the answer to this one.  Think I know from testing but want to be sure.   I have a SP on  MSSQL 2000 that I created.  Within the table I call 6 update statements.  All my params are input. I developing software using VS 2008 PRO with a typed dataset.  I added the stored procedure to my tableadapter and it created the subsequent update() method with an int return type.  I coded a statement to test the return value like so... int Success = tableadapter.update(value1,value2,etc) I examined the Success variable and found it to be 6. I looked at another SP that calls 7 update statements within it and the return value after being called was 7. I did not specify any return value in my SP.  I can only presume that the SP is by default returning the aggregate amount of rows affected.  My question is if my presumption is correct.  My reason for asking is I would like to know this value is reliable for testing that all 6 update statements in the SP were  successful.    Thank you.

How to get the return value from stored procedure

Hi,I  not getting the return value from stored procedure that I have written so how to get that plzz its urgent I have return the procedure as ALTER PROCEDURE [dbo].[sp_AddPaySlip]  -- Add the parameters for the stored procedure here @inDMLType varchar(1), @EmpID varchar(2000) = '', @BankAccountNumber nvarchar(50) = '', @NoOfDaysWorked varchar(500)='', @GrossSalary varchar(2000) = '', @Basic varchar(500) = '', @PerformanceAllowance numeric=0, @PersonalAllowance numeric=0, @Hra numeric=0, @PF numeric=0, @PTax varchar(10)='', @Tds numeric=0 , @Total varchar(500) = '', @NetPay varchar(500) = '', @PFAccountNumber varchar(100)='', @Year varchar(10)='', @Month varchar(10)='', @ou_intRetValue int=0 output AS BEGIN declare @l_sqlqry nvarchar(1000) ,@intError INT ,@inCnt int --set @l_sqlqry ='' --set @interror = 0-- Set @inCnt =0 --If @inDMLType  not in ('I') goto Insufficient_Data  --IF @inDMLType  ='I' -- for Inserting  DECLARE @result int BEGIN /*if exists(Select 1 from users where Year(DateofJoin) >= @Year and EmpID = @EmpID) Begin set @interror = 2 End if exists(Select 1 from users where month(DateofJoin) > @Month and EmpID = @EmpID) Begin -

inserting data after caliculation using stored procedure

hi my requirement is like i want to insert data to table after caliculationliketable name salaryhikecolumns salaryinput,20%hike, 25%hike and 30%hikesalaryinput column details  to be input by the user and hike is to be caliculated and inserted with 20%hike, 25%hike and 30%hike are columns of same table.plz help me.thank you very much.

Stored Procedure In 3 Layer Architecture

Dear All,     I am using stored procedure in my Web application.I am creating SQL  Command binding this command with Stored procedure name and parameters and executing.The problem is for each Stored procedure i need to create separate function for each stored procedure defined.Is there any way that I can define a single function for n number of stored procedure. 

Linq to SQL with XML data type

Hi guys, I need your help.  I am having some issues updating sql table with Linq to Sql dataContext objects.  When I call SubmitChanges with modifications to the data, the simple types (int, varchar) get updated, but I also have an XML data type and this does not get updated.  Below is a sample of my code to update an existing record.                   Dim db As New EnrollmentDataClassesDataContext(True)                                                 Dim orderIdGuid As New Guid("9EA26E39-07F1-4C1F-B7CD-B6D323DF9D70")                Dim orderDetailEntity As OrderDetail                orderDetailEntity = (From checkout In db.OrderDetails Where checkout.OrderId = orderIdGuid Select checkout).SingleOrDefault                If Not orderDetailEntity Is Nothing Then          

How to get the return value from a stored procedure


Hi everyone..

I've a stored procedure and procedure works well. In that procedure, there is one output parameter which i need to get returned.

this is my procedure..

ALTER PROCEDURE [dbo].[tgms_reclass_PO_bip](@po VARCHAR(20), @old_gl VARCHAR(20), @new_gl VARCHAR(20),@output varchar(500) out )

IF (SELECT COUNT(*) FROM mm2po WHERE scode = @po) = 0
    --SET @output = '1'
    SET @output = 'Invalid PO Number'

Check if Old GL Code is valid
IF (@output = '' AND (SELECT COUNT(*) FROM acct WHERE scode = REPLACE(@old_gl,'-','')) = 0)
    --SET @output = '2'
    SET @output = 'Invalid Old GL Account'

Check if New GL Code is valid
IF (@output = '' AND (SELECT COUNT(*) FROM acct WHERE scode = REPLACE(@new_gl,'-','')) = 0)
    --SET @output = '3'
    SET @output = 'Invalid New GL Account'

Check if the PO has been invoiced or paid

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend