Solved

Linq to SQL Using  single sp for insert and update

Posted on 2010-09-11
3
523 Views
Last Modified: 2013-11-11
Hi EE,

I have sps that besides including both insert and update code, they also call other sps.
Can I use sps like this with Linq to SQL.
If I can, how would I use it?
I am using sql server 2005.
Thanks
0
Comment
Question by:Sheritlw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 33655592
Hi Sheritlw;

Yes you can, that should not be an issue.

First create your DataContext using the ORM design tool.
Drag the Stored Procedure onto the design surface, right side of the designer.
Now in code create an instance of the data context for example :

Dim db As New DataContextName()

Then execute the SP, let say the SP is called InsertAndUpdate, something like this :

db.InsertAndUpdate( "The parameters you need to pass in" )

thats it.

Fernando
0
 

Author Comment

by:Sheritlw
ID: 33655594
Sounds good to me,
Thanks
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 33656613
Not a problem, glad to help.  ;=)
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

617 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