C# - How To Convert The Result Of A Stored Procedure In A Dbml File

May 6, 2010

I have a MVC project that has a Linq to SQL dbml class. It is a table called Clients that houses client information. I can easily get the information to display in a View using the code I followed in Nerd Dinner but I have added a stored procedure to the dbml and it's result set is of IQueryable, not IQueryable. I need to convert IQueryable to IQueryable so I can display it in the same View. The reason for the sproc is so I can pass a search string tothe sproc and return the same information as a full list but filtered on the search. I know I can use Linq to filter the whole list but I don't want the whole list so I am using the sproc.

Here is the code in my ClientRepository with a comment where I need to convert. What code goes in the commented spot.

public IQueryable<Client> SelectClientsBySearch(String search)
{
IQueryable<SelectClientsBySearchResult> spClientList = (from p in db.SelectClientsBySearch(search) select p).AsQueryable();
//what is the code to convert IQueryable<SelectClientsBySearchResult> to IQueryable<Client>
return clientList;
}

View 1 Replies


Similar Messages:

Multiple Single-result Sql Server Stored Procedures Or Single Multple-result Stored Procedure?

Aug 9, 2010

Background: I use stored procedures exclusively for an ASP.NET application. I am using a DataReader to load a dataset object.

View 4 Replies

DataSource Controls :: How To Convert The Oracle Stored Procedure To Sqlserver 2005 Stored Procedure

Apr 2, 2010

This is surareddy. i nead some small clarification in the "Stored Procedure"

how to convert the oracle Stored Procedure to sqlserver2005/2008 Stored Procedure.

right now i am enhancing the project that project already developed the oracle Stored Procedure. now our company is using sqlserver 2005/2008.

how to convert the Oracle Stored Procedure to sqlserver 2005 Stored Procedure

View 4 Replies

SQL Reporting :: How To Add Stored Procedure Result Set Columns To Typed Dataset And Dataset To RDLC File

Jan 9, 2011

Till now I used to design RDLC file before and assigned typed dataset table columns.Report processing mode is local. But now my stored procedure returns different columns based on condition i.e columns are not fixed every time. Now I need to add that columns to typed dataset and dataset is assigned to RDLC file. So dataset and RDLC files are create dynamically based on stored procedure result set columns.

View 1 Replies

MVC :: Execute Stored Procedure And Pass Result To View

Jun 19, 2010

I created a stored procedure in my MVC project. I need to execute it and pass result to view form. How can I do this?

View 1 Replies

C# - Accessing The Result Set Of A Stored Procedure, Executed Using SqlDataSource.Select?

Jul 21, 2010

I'm programming a webpage in ASP.NET which displays a list of students not listed as participants in something, and upon clicking a student name shows you a brief summary of their details, so the user can ensure they're selecting the right person.

My code currently correctly obtains their ID, adds it as a parameter to my stored procedure and executes the procedure;

[code]....

However, when I try to access the results I get the following error:

System.NullReferenceException: Object reference not set to an instance of an object.

Upon debugging, there don't seem to be any results returned... but when running just the stored procedure in SQL Server with the same data, it does return a single row, as expected.

How do I access this result so I can bind it to my fields?

(I am working in ASP.NET 3.5 in Visual Studio 2008, with SQL Server 2008.)

View 2 Replies

DataSource Controls :: Accessing The Result Set Of A Stored Procedure - How To Fix This Error

Jul 27, 2010

I'm programming a webpage in ASP.NET which displays a list of students not listed as participants in something, and upon clicking a student name shows you a brief summary of their details, so the user can ensure they're selecting the right person. Each student is identified by a unique ID.

My code currently correctly obtains their ID, adds it as a parameter to my stored procedure and executes the procedure;

[Code]....

However, when I try to access the results, with say dv.Table.Rows[0], I get the following error:

[Code]....

Upon debugging, there don't seem to be any results returned... when running just the stored procedure in SQL Server with the same data, it does return a single row, as expected.

View 2 Replies

DataSource Controls :: Repeating Data In Stored Procedure Result?

Jan 27, 2010

I am bulding a dvd catalog and have a table called DVD which holds all my details about each dvd except Genre, Director and Actor as I want more than 1 Genre, Director, Actor per DVD so put these in seperate tables to avoid repeating the data and used a joining tabe to join the tables so the tables I have are

DVD, Genre, Director, Actor, DVDGenre, DVDDirector and DVDActor

I have now written a stored procedure to pull the info about 1 DVD out of all the tables to display on the webpage I have now got the info I want out of the tables but as the data is now in 1 table I have repeating data is there a way to stop the data repeating the stored procedure i have written is

[code]....

View 8 Replies

DataSource Controls :: Xsd And Stored Procedure With Multiple Result Sets

Jun 12, 2010

Just after some advice I have a stored procedure that returns several tables. I then need to loop through the tables and create dynamic gridviews using the data. At the moment this stored proc is called using

[Code]....

I have used an xsd file to populate everthing else, but due to this returning multiple tables i wasn't sure how this works should it just be in its own xsd? as all the oather i just get a datatable where as with this i need a dataset... how this makes sense...

View 2 Replies

SQL Server :: Assign Result Of Count Stored Procedure To C# Variable?

Aug 7, 2010

I have an aggregate stored procedure (named sp2) that returns a count of records meeting a certain criteria ASrecCount. I am using a DAL per the ASP.NET tutorial and have created a Table Adapter (named
sp2TableAdapter) with GetData and Fill methods. I have a button on an ASP.NET page that launches an event handler. In the button's event handler, I have this line: sp2TableAdapter sp2 = new sp2TableAdapter();
What works so far:

This code will bind the value of sp2 to a data control:

sp2TableAdapter sp2 = new sp2TableAdapter();
DropDownList1.DataSource = sp2.GetData();
DropDownList1.DataValueField = "recCount ";
DropDownList.DataTextField = "recCount";
DropDownList1.DataBind();

When running this page and clicking the button, the numeric value of recCount returned from sp2 is bound to the DropDownList control and 1 row is poplated with the recCount value (in my case 1451).

Problem:
In the event handler, I do not want to bind the value of recCount to a control, but want to to use it in some logic as an integer. What is the C# code that will do this? (In place of the DropDownList control lines above)

View 2 Replies

How To Display Stored Procedure Result Set Rows As Columns In RDLC Report

Jan 12, 2011

Below is the result set when I execute my stored procedure. Based on condition no.of rows will change. I am using typed dataset to store result set.

NSV QTY MONTH/YEAR

264.95 31248 APR/07
273.23 34044 MAY/07
230.96 22232 JUN/07
711.93 81992 JUL/07
427.23 50345 AUG/07
297.90 36961 SEP/07
495.37 43079 OCT/07
648.48 52428 NOV/07
622.06 46364 DEC/07
407.02 46461 JAN/08
605.45 73439 FEB/08
224.81 28121 MAR/08
308.12 33356 APR/08
328.22 35605 MAY/08
372.41 34107 JUN/08

I have to show above result in RDLC file Like below.

APR/07 MAY/07 JUN/07................JUN/08
264.95 273.23 230.96.................372.41
31248 34044 22232 ...............34107

RDLC report? If I use table control,

View 2 Replies

SQL Reporting :: How To Display Stored Procedure Result Set Rows As Columns In RDLC Report

Jan 12, 2011

Below is the result set when I execute my stored procedure. Based on condition no.of rows will change. I am using typed dataset to store result set.

NSV QTY MONTH/YEAR

264.95 31248
APR/07
273.23 34044
MAY/07
230.96 22232
JUN/07
711.93 81992
JUL/07
427.23 50345
AUG/07
297.90 36961
SEP/07
495.37 43079
OCT/07
648.48 52428
NOV/07
622.06 46364
DEC/07
407.02 46461
JAN/08
605.45 73439
FEB/08
224.81 28121
MAR/08
308.12 33356
APR/08
328.22 35605
MAY/08
372.41 34107
JUN/08

I have to show above result in RDLC file Like below.

APR/07 MAY/07 JUN/07................JUN/08
264.95 273.23 230.96.................372.41
31248 34044 22232 ...............34107

View 3 Replies

Forms Data Controls :: Returning Single String Result Through Stored Procedure

Jun 22, 2010

I am trying to return single string result through a stored procedure and Linq. This works fine when I test the stored procedure but it is not returning the value to the page. The value returned is always 0 which is the return value. This is the stored procedure:

ALTER PROCEDURE Login
@CustomerName nvarchar(50),
@Password nvarchar(50) output
As
Select @Password=Password
From Customers
Where Customers.CustomerName=@CustomerName

This is the vb
ALTER PROCEDURE Login
@CustomerName nvarchar(50),
@Password nvarchar(50) output
As
Select @Password=Password
From Customers
Where Customers.CustomerName=@CustomerName is the code created by the designer

This is the designer function
<FunctionAttribute(Name:="dbo.Login")> _
Public Function Login(<Parameter(Name:="CustomerName", DbType:="NVarChar(50)")> ByVal customerName

As String, <Parameter(Name:="Password", DbType:="NVarChar(50)")> ByRef password As String) As IntegerDim result
As IExecuteResult = Me.ExecuteMethodCall(Me, CType(MethodInfo.GetCurrentMethod,MethodInfo), customerName, password)
password = CType(result.GetParameterValue(1),String)
End Function

View 4 Replies

DataSource Controls :: Stored Procedure With Multiple Result Sets - Binding To Gridview?

Feb 3, 2011

I am using a sql stored procedure which returns multiple result sets. By default Sql Datasource is binding the first result set to gridview. I want the second result set to be binded. I browsed all the properties in Sql datasource but could not find one to set this.

View 4 Replies

DataSource Controls :: Do Not Use Or Call Any Stored Procedure But It Says "Could Not Find Stored Procedure 'xxxxx'?

Dec 9, 2010

Initially, I have tried to use stored procedure. But I changed my mind and preferred to call sql query in codebase with command text. However, it stills tries to find initially-called stored procedure (which is neither called or exists).I think that it is related caching. But I tried it with different browsers it did not work.What might be the reason?

View 4 Replies

SQL Server :: Have A Stored Procedure Execute Another Stored Procedure During Time Period?

Jan 28, 2011

I could probably figure this out if I tried to, but I have been working so long on code, I'm a little fried

I have a stored procedure, and I want to execute another stored procedure during a time period of lets say 1/1/2011 to 12/31/2011

How Would I accomplish this?

View 4 Replies

DataSource Controls :: Execute A Stored Procedure Within A Stored Procedure?

Jan 18, 2010

Does anybody if it is possible that a stored procedure returns rows which is the result of the execution of another sp? Something like..

[Code]....

View 11 Replies

DataSource Controls :: How To Call A Stored Procedure In Another Stored Procedure

May 13, 2010

i want to return output parameter from 1 storeprocedure. into another stored procedure.

View 7 Replies

ADO.NET :: CSV File Import Into Database Through Stored Procedure

Sep 1, 2010

I want to import file ( CSV ). how to write a stored procedure for this purpose or any other way to import a CSV file into my database.

View 1 Replies

DataSource Controls :: How To Write The Stored Procedure In .cs File

Sep 2, 2010

i am using .net 1.1 and sql 2000.i need to write the stored procedure in .cs file.is it possible.if so how?

View 2 Replies

SQL Server :: Write Code Of Stored Procedure / Create Stored Procedure And Write Select Statement In It

Nov 23, 2010

how can I create stored procedure and write my select statement in it, I know how to create dataset then put type stored procedure and assign it to the sp ... what I want is writing my sp... how can I make it ?

check the following code, this is what I want to write put I don't know where or how !

CREATE STORED PROCEDURE SP_CATEGORY

@CATEGORY VARCHAR(30)

AS

BEGIN

SELECT LATIN_NAME, ENGLISH_NAME, ARABIC_NAME, CATEGORY

FROM FLORA, CATEGORY_LIST

WHERE FLORA.CATEGORY=CATEGORY_LIST.CATEGORY_NAME AND CATEGORY_LIST.CATEGORY_NAME IN (SELECT * FROM SPLITLIST(@CATEGORY, ','))

END

where can I write this code ?!

View 5 Replies

Asp.net -to Update .dbml File

Aug 12, 2010

How to update .dbml file after making some changes in the database?

View 4 Replies

How To Reference A DBML File In An Aspx File

Apr 3, 2010

I have a ascx file and dbml linq file. i need to write c# script inside the ascx file, for that i need to use .dbml file. I dnt know how to reference it in my ascx file

View 6 Replies

Forms Data Controls :: Working Procedure With Varbinary From Existing Stored Procedure?

Feb 22, 2010

[Code]....

i have a stored procedure with this values and i need just to make a button that will send something to "Equip" column,how to do it? write the values on my webpage and make a button to exec the procedu

View 1 Replies

How To Create Stored Procedure In Sql Server And Call That Procedure From C# Code

Sep 1, 2010

I am trying to create the following stored procedure in sql server Lat and Lng are the parameters being passed from c# code behind .But I am not able to create this stored procedureit indicates with error saying undefined column name Lat,Lng

CREATE FUNCTION spherical_distance(@a float, @b float, @c float)
RETURNS float
AS
BEGIN
RETURN ( 6371 * ACOS( COS( (@a/@b) ) * COS( (Lat/@b) ) * COS( ( Lng/@b ) - (@c/@b) ) + SIN( @a/@b ) * SIN( Lat/@b ) ) )
END
sqlda.SelectCommand.CommandText = "select *, spherical_distance( Lat, 57.2958, Lng) as distance
from business
[code]...

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved