Solved

entity DataTable

Posted on 2014-01-10
2
375 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:sevensnake77
2 Comments
 
LVL 16

Accepted Solution

by:
Easwaran Paramasivam earned 500 total points
Comment Utility
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:sevensnake77
Comment Utility
thanks
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

763 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now