Thursday, 15 May 2014

c# - Retrieve data from SQL Server stored procedure into an array -


I am trying to get data from my database and put it in an array.

I tried this code:

  dataclassdatentex DS = new dataclassdetectex (); Secure Zero Page_Old (Object Sender, EventAGRS E) {List & lt; String & gt; _news = New List & lt; String & gt; (); For (int i = 0; i & lt; = 4; i ++) {_news.Add (DS.sect_top_with_news). Elementut (I) .ostring ()); }}  

But whatever I want does nothing and gives me this error:

Specified arguments range from legitimate values was out.
Parameter Name: Index

And this is the process I used to store:

  Select the manufacturing process as the select_top_five_news return Select Top 5 * News Dec. DESC News Order  

The problem is that the result of stored procedure is given as the single result and I Requirement of Loop in Record for everyone to get it

Anyone Dd Please! Or is there any other goal in the same way?

Since your process is already filtering data for you, you should only do the following The procedure will return 5 in the results, so whatever you have received is getting you. If you need the default entities, you need to add more missing items to the loop, and not drag existing results out of your results.

  DataClassesDataContext DS = new DataClassesDataContext (); Secure Zero Page_load (object sender, event case e) {var _news = DS.select_top_five_news (). ToList (); }  

If you were using a unit directly you would do this.

  DataClassesDataContext DS = new DataClassesDataContext (); Protected Zero Page_Load (Object Sender, EventArgues E) {var _news = DS.News.OrderBy (n => n.id). Take (5) .Olist (); }  

No comments:

Post a Comment