?
Solved

entity DataTable

Posted on 2014-01-10
2
Medium Priority
?
408 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

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

801 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