views:

213

answers:

3

Is it possible to use Linq-to-Sql to execute a stored procedure that does not return an output?

+5  A: 

DataContext.ExecuteCommand?

Jon Skeet
+4  A: 

In the Server Explorer window, browse and find your sproc. Drag it over to the Methods area in the Linq-to-Sql designer.

This stored procedure is now available as a method in your DataContext object.

e.g.

Your sproc name is IncrementCustomerVisit and it takes one parameter of type int.

In your app code:

using (DataContext db = new DataContext())
{
   db.IncrementCustomerVisit(someCustomerID);                 
}
p.campbell
A: 
db.ExecuteCommand("exec myStoredProcedureName");
Paul Rowland