DataSource Controls :: Use Stored Procedures From LINQ With A Using Clause ?

May 25, 2010

Ive created a new LINQ To SQL class and dragged several tables across from my server, in my code I access them like this

[Code]....this is all ok, however, I have several stored procedures that I want to use as well, but when I drag the stored procedures across I get a compilatiopn error

Error 60 'DB_BL.DB_BLDataContext': type used in a using statement must be implicitly convertible to 'System.IDisposable'

how do I use stored procedures from LINQ with a using clause ?

View 7 Replies


Similar Messages:

DataSource Controls :: LINQ With Stored Procedures?

Mar 29, 2010

Im new to ASP.NET (Normally use PHP), and im currently designing a website in VB.NET and SQL Server.

When using LINQ to SQL i know that it uses parametarized queries and we dont need to add them.

So do we need to use Stored Procedures in LINQ (for security reasons)???, If yes How

View 3 Replies

DataSource Controls :: Using Sql Stored Procedures - Does Linq Still Make Sense?

Jan 4, 2010

If this is not the appropriate forum for this I didn't see any linq specific forum listed.

I am about to start a new project and I would like to use it as an opportunity to update myself with the newer technologies, like ajax and linq.


All my database CRUD operations will be done by sql stored procedures, does linq still make sense when doing that? I watched a couple introductory videos on linq and none of them dealt with stored procedures, thats why I'm wondering.

View 10 Replies

DataSource Controls :: Good Way To Use Linq With Update Stored Procedures?

Jun 9, 2010

I like to use my own stored procs as much as possible.

That way I know exactly what's happening and I can explain and control things.

I'm using stored procs with LINQ to SQL for CRUD operations.

For select, insert and delete - using stored procs with LINQ to SQL is pretty straightforward.

However, if I want to use my own custom stored procs with L2S for updates what's the best way to accomplish this?

Can you provide some code that shows the best approach that you would personally choose for this?

View 1 Replies

DataSource Controls :: LINQ Using Stored Procedures And MvcContrib Grid With Pagination?

Jan 12, 2010

I have been chasing this erorr all day and coming up blank. I created a stored proceudre(fairly complicated logic), added it to the context, and set the return type to a specific entity type.

It generated this:

[Function(Name="dbo.usp_ServiceTemplateSelectByFkID")]
public ISingleResult<ServiceTemplate> usp_ServiceTemplateSelectByFkID([Parameter(Name="FkId", DbType="Int")] System.Nullable<int> FkId)
{
IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), FkId);
return ((ISingleResult<ServiceTemplate>)(result.ReturnValue));
}

I call it from my service with the following method:

public ISingleResult<ServiceTemplate> GetByFkId(int FkId)
{
return Db.usp_ServiceTemplateSelectByFkId(FkId);
}

I have tested the stored procedure and it returns the results I want. When I make the service call from the controller, it doesn't error out, however, it should return 4 records in this instance and instead, it returns the same 4 records (repeating the first record 4 times).

In addition, in my controller code, I am using the MVCContrib ToPagedList() method which doesn't appear to work with the ISingleResult interface (forward only cursor, I'm guessing). I have attempted converting the service results to IQuery, List, and Array, however, I still have the problem with the first record being repeated 4 times.

View 3 Replies

DataSource Controls :: Stored Procedures Are Not Showing Up Correctly In The Stored Procedure Drop Down

Apr 27, 2010

I am using Visual Studio 2008 and SQL Server 2008 and have added a SQL datasource to my form.

When I configure the datasource, I choose my connection string which looks like this in my webconfig:

<connectionStrings>

<add
name="PSFSPRD_ConnectionString"
connectionString="Data

The database I am using has a schema called EQB and as such, my stored procedures are named as EQB.usp_SelectFunds, EQB.usp_SelectAccount, etc.

On the select tab of the Configure Data Source screen, I choose to use a stored procedure. The dropdown shows my stored procedures, however, the schema name does not show up in front of the stored procedures in the drop down. I see only usp_SelectFunds, usp_SelectAccount, etc.

I select one of the stored procedures and when I click TEST, I get the message that the stored procedure is not found. If I instead choose to use a SQL statement instead on the configuration screen and enter EXEC EQB.usp_SelectFunds and click TEST, it works fine.

Why are my stored procedures not showing up correctly in the stored procedure drop down and how can I fix this?

View 3 Replies

DataSource Controls :: Encrypt All Stored Procedures At Once?

May 7, 2010

How can I encrypt all Stored Procedures of a database at once?

View 3 Replies

DataSource Controls :: Linq - Update Statement Where Clause?

May 25, 2010

I am using Linq to SQL. Tables have timestamp columns and I am using regular Linq methodology in ASP.NET MVC.I do use detached entities and always try to do updates without first querying the database for the original entity. To update an entity I use context.Attach(entity, true) followed by context.SubmitChanges() and all is fine. The sql statement that gets executed looks like:

[Code]...

View 7 Replies

DataSource Controls :: Do Stored Procedures Execute Locally

Apr 10, 2010

we have sql server running on a server.

when person A connects to sql server from their machine and executes a stored procedure (a stored procedure which runs a query and sends an email) - it executes and the email is received.

when person B connects to sql server from their machine and executes the same stored procedure, it executes but the email is never received.

does this mean the stored procedure is executing locally on both users machines?

if not....then why does person B's execution of the stored procedure not generate the email?

View 2 Replies

DataSource Controls :: How To Write And Use Dynamic Stored Procedures In C#

May 28, 2010

I want to write dynamic store procedure means 1 select_sp, 1 update_sp, 1 insert_sp, 1_delete_sp for all tables.

How it is used in secured manner.

View 2 Replies

DataSource Controls :: What Is The Best Method To Log Executed Stored Procedures

Apr 6, 2010

Should I just write to file before a stored procedure is executed or should I log the stored procedure into a table? If the latter one is recommended, how should I go about doing that?

View 4 Replies

DataSource Controls :: Sqldatasoure, Mysqldatareader And Stored Procedures?

Jan 8, 2010

I am having a problem returning a value from a stored procedure when using SqlDataSource. The stored procedure is executing because 'invoice_no is incrementing but Myreader.HasRows is always false.

Here is the table definition

`invoice_no` int(10) NOT NULL AUTO_INCREMENT,
`employee` varchar(50) DEFAULT NULL,
`create_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`invoice_no`)

Here is the stored procedure:

CREATE PROCEDURE `GetInvoiceNumber`(IN username VARCHAR(50), OUT InvoiceNum INT)
BEGIN
INSERT INTO invoice (employee)
VALUES (username);
SELECT MAX(invoice_no) INTO InvoiceNum FROM invoice;
END

And here is my code.

[Code]....

View 2 Replies

DataSource Controls :: Can Create Overloaded Stored Procedures

Jan 6, 2010

can we create overloaded stored procedures in sql server

View 7 Replies

DataSource Controls :: Create Stored Procedures Using Vbscript?

May 12, 2010

how to create stored procedures using vbscript, and how to pass the parameters to the stored procedures...

View 6 Replies

MVC :: SQL Server 2005 - Stored Procedures - NO LINQ?

Jan 27, 2010

I'm totally new to MVC (started this morning), and am totally at a loss where to start. I need to rebuild an existing website. I already have a SQL Server 2005 database with tables and stored procedures. In the old version of the website, I built a function to call stored procedures and return the results as a datareader in VB.Net.

I want to use ASP.NET MVC with C#.

The first question I have is: Where would I put the code for the function that calls stored procedures ?

My second question is: Where do I go from there? I just need to get a sense of the basic way to handle presenting a dynamic website. I just want to start out with a Site.Master and display my menus which need to be generated dynamically from my database. I've been googling all day and I haven't really found any posts which answer all of my questions.

View 4 Replies

ADO.NET :: Linq To Sql Column Mismatch Using Stored Procedures?

Aug 26, 2010

I'm using Linq to Sql to call some stored procedures for more complex work; is there any way Linq to Sql can tell me when the output columns from the stored procedure do not match the properties of my entity object? It seems that Linq to Sql tries its best to match the columns and ignores any mismatches.

View 8 Replies

ADO.NET :: Return Type Of Linq To SQL Stored Procedures?

Sep 20, 2010

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)
{
this.orderid=orderid;
}
public string orderid {get;set;}
public string orderno{get;set;}
}

View 1 Replies

ADO.NET :: Inserting Records Using Stored Procedures In LINQ To SQL In MVC

Mar 11, 2011

I am inserting records using stored procedures in LINQ to SQL in MVC.but i don't know the proper way.

View 1 Replies

DataSource Controls :: SqlDataSource How To Change The Stored Procedures At Run Time

Aug 18, 2010

Is it possible to change the select, insert and update stored procedure of an SqlDataSource at run time. I don't mean to change the definition of the stored procedure, but I mean to change the assignment, i.e. To change the select stored procedure from "selectSP1" to "selectSP2" at run time. Is it possible?

View 4 Replies

DataSource Controls :: Executing Two Stored Procedures That Either Pass Together Or Fail Together?

Mar 2, 2010

I open a sqlconnection and sqlcommand. I execute a stored procedure and get the scope_identity from that procedure to be used within another procedure that needs to be fired. Unfortuntley if the second procedure fails forwhatever reason the data change for the first procedure commits anyway. I kind of want to do a began transaction end transaction on the c#.net side. Also I need to execute a stored procedure multiple times....

View 2 Replies

DataSource Controls :: How To Execute 3 Stored Procedures On Page Load

Mar 30, 2010

In a pickel here. When I run this code:

[code]...

The only Stored procedure execute is the last one TSD_UpdateTimeCardEndofDay

View 3 Replies

DataSource Controls :: Errors In Passing Values To Stored Procedures?

Jul 28, 2010

I am passing values from textboxes on the webform to my stored procedures where it should insert values passed.

It is giving an error like Cannot implicitly convert type 'string' to 'System.Data.SqlClient.SqlParameter' at place where I am cmdselect.Parameters.Add("@PackageName", SqlDbType.VarChar, 50) = PN; where PN is string type .

View 2 Replies

ADO.NET :: Linq To Sql Stored Procedures - Set Correct Return Type?

Dec 15, 2010

I've recently inherited an ASP.NET 2.0 project from other developers and they have a LinqToSql datacontext with stored procedures. I've been asked to modify one of the SPs which is essentially just adding a couple columns to the database table and then those to parameters to the SP. So I delete the existing SP from the L2S context and drag in the new one with the additional fields, and all hell breaks loose. Suddenly I get over 20 errors! What seems to have occured is L2S has modified many other stored procedures that I haven't even touched and changed the return type from ISingleDefault<some object> to int. I've never used stored procedures before with L2S so I don't know if this is standard behavior or not. Does anyone know why this has happened and how to fix it to set the correct return type?

View 3 Replies

C# - Linq-To-SQL CreateDatabase Doesn't Create Stored Procedures?

Feb 11, 2011

I have Linq-to-SQL DataContext and I run:

datacontext.CreateDatabase()

This works fine.

Recently I dragged a stored procedure onto the methods pane. I was thinking this stored procedure was now part of the datacontext and would get regenerated when creating the database.

View 2 Replies

DataSource Controls :: Prevent Server/Database To Have SQL Stored Procedures Encrypted?

May 13, 2010

I have access to two servers, one with my development database on, and another with the live database on.

All SQL Stored Procedures, Functions, Views are encrypted on the live database (using WITH ENCRYPTION in my query)

However I'm concerned I might accidentally encrypt a bunch of SProcs on my development database meaning I can no longer view/edit that code.

I have full control over the server and database, and was wondering if there is a way I can prevent these from being encrypted, therefore throwing up an error when this is attempted?

View 4 Replies







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