Solved

entity DataTable

Posted on 2014-01-10
2
388 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
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:sevensnake77
ID: 39782403
thanks
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

789 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