mobileNavlogo
headerlogo

Accessing stored procedures using LINQ in vb.net

Blog Author

Tekslate

Published Date

19th October, 2020

Ratings

Views

914

  • Share this blog :

 

Accessing stored procedures using LINQ

Open ServerExplorer

Open NorthWindDataConnection

Drag & drop CustOrderList (Stored Procedure) on Form (which contains tables we drag & dropped (cust, order, - - - -))

(The stored procedure we already have)

Rclick anywhere on the design and click ShowMethodSpan. Now a window will be opened showing all stored procedure

Save

Note: The above steps will add the definition of the stored procedure with LINQ to SQL classes.  

Inclined to build a profession as VB.Net Developer? Then here is the blog post on, explore VB.Net Training

The stored procedure used in LINQ:

ALTER PROCEDURE CustOrderList

@ Customer ID nchar (5)

AS

SELECT Product Name, Total = SUM   - - >  (quantity)

FROM ProductsP, [Order Details] Od, Orders O, Customers c

WHERE C.CustomerID = @ Customer ID

AND C.CustomerID = O.CustomerID

AND O.OrderID = OD.OrderID AND

OD.ProductID = D.ProductID

GROUP BY Product Name

Click on GridView2 task and edit columns

Expand Command Field à Select à Add

Button type: button

SelectText: ShowOrders

Double click on GridView2

“GridView2_SelectedIndexChanged

String cid;

TableCell tcCID = (TableCell) GridVIew2. SelectedRow. Cells [3];

cid = tcCID.Text;

Response.Redirect (“ShowOrdersHistoryByCID.aspx? cid = “ + cid);

Website [menu] - - >Add NewItem – Name: ShowOrdersHistoryByCID

Place a GridView Control

// Page_Load

String CustomerId = request.QueryString [“cid”];

NorthWindDBDataContext dc = new NorthWindDBDataContext ();

Var ordersHistory = dc.CustOrderHist (CustomerId);

GridView1.DataSource = orderHistory;

GridView1.DataBind ();

For an in-depth knowledge, click on below

About Author
Authorlogo
Name

TekSlate

Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills .

Related Blogs

Write For Us