Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

entity DataTable

Posted on 2014-01-10
2
Medium Priority
?
418 Views
Last Modified: 2014-01-15
how can i take this
 private DataTable GetRecords()
   {
    
         using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString()))
             {
           // Open the connection. 
          
          conn.Open();
          SqlCommand command = new SqlCommand();
          command.Connection = conn;
          command.CommandTimeout = 15;
          command.CommandType = CommandType.StoredProcedure;
          command.CommandText = "storedprocedureconnect";

          
           command.Parameters.Add("@paramvalue1", SqlDbType.VarChar, 6).Value = "myvalue";
           command.Parameters.Add("@paramvalue2", SqlDbType.Int).Value = 0;
           SqlDataAdapter dA = new SqlDataAdapter();
                      DataSet objDs = new DataSet();
           dA.SelectCommand = command;
           dA.Fill(objDs);
           return objDs.Tables[0];
      }
}

Open in new window

And convert it to use
 Entities entityBuilder = new Entities();
And entity storedprocedure function?
0
Comment
Question by:Seven price
[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 Comments
 
LVL 16

Accepted Solution

by:
Easwaran Paramasivam earned 1500 total points
ID: 39773847
EDMX file also generates derived ObjectContext and all entities by default. If not, create context accordingly.

Using below code the SPs are called.

•objectContext.ExecuteSqlCommand("storedProcedureName", SqlParameters) for SPs not returning record set

•objectContext.ExecuteStoreQuery<ResultType>("storedProcedureName", SqlParameters) for SPs returning record set. ResultType must have properties with same names as columns in result set.
0
 
LVL 9

Author Closing Comment

by:Seven price
ID: 39782403
thanks
0

Featured Post

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

610 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