Click here to Skip to main content
15,886,518 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionCan't Delete Cookie being accessed from subdomains Pin
Mateobus1-Dec-08 5:26
Mateobus1-Dec-08 5:26 
QuestionGridview binding issue Pin
mpavas1-Dec-08 3:14
mpavas1-Dec-08 3:14 
AnswerRe: Gridview binding issue Pin
Muhammad Gouda1-Dec-08 3:41
Muhammad Gouda1-Dec-08 3:41 
GeneralRe: Gridview binding issue Pin
mpavas1-Dec-08 4:35
mpavas1-Dec-08 4:35 
Questionrecommendation on retriving data from DB Pin
Tugbay Sahin1-Dec-08 2:16
Tugbay Sahin1-Dec-08 2:16 
AnswerRe: recommendation on retriving data from DB Pin
Nishant Singh1-Dec-08 2:28
Nishant Singh1-Dec-08 2:28 
AnswerRe: recommendation on retriving data from DB Pin
Abhijit Jana1-Dec-08 2:28
professionalAbhijit Jana1-Dec-08 2:28 
AnswerRe: recommendation on retriving data from DB Pin
N a v a n e e t h1-Dec-08 2:56
N a v a n e e t h1-Dec-08 2:56 
Tugbay Sahin wrote:
I retrive data from my DB using data adapter then fill a data table and then I fill my entities from that data table then create an arraylist then bind it.


This is going to be slower. You are doing one step extra.

DataTable is filled using a data reader instance internally. So when you retrieve 10 records from DB, you will loop 20 times to fill your entity class (10 for filling datatable and 10 for filling class from this datatable).

When you use strongly typed entity classes, you don't need data table at all. You get the result in data reader, loop through it and fill your custom class instances. Don't use ArrayList, use a generic List(T) instead. This should be much faster.

Example (Assuming Customer is your entity class with two properties name and age)
public List<Customer> GetCustomers(){

     // initialize connection, command etc
     List<Customer> customers = new List<Customer>();
     using(SqlDataReader reader = command.ExecuteReader()){
         if(reader.HasRows){
             int customerName = reader.GetOrdinal("name");
             int customerAge = reader.GetOrdinal("age"); 
             while(reader.Read()){
                 customers.Add(new Customer(reader.GetInt32(customerAge),
                         reader.GetString(customerName));
             }
         }
     }
     return customers;
}
Data table is not type safe. This method will help you to avoid many bugs and your code will look much cleaner.

Hope this helps


AnswerRe: recommendation on retriving data from DB Pin
Tugbay Sahin1-Dec-08 3:04
Tugbay Sahin1-Dec-08 3:04 
AnswerRe: recommendation on retriving data from DB Pin
Muhammad Gouda1-Dec-08 4:16
Muhammad Gouda1-Dec-08 4:16 
QuestionHow can I retrieve the source code of the content in an iframe. Pin
a_b1111-Dec-08 1:58
a_b1111-Dec-08 1:58 
AnswerRe: How can I retrieve the source code of the content in an iframe. Pin
Dominic Goulet1-Dec-08 2:32
Dominic Goulet1-Dec-08 2:32 
AnswerRe: How can I retrieve the source code of the content in an iframe. Pin
Abhijit Jana1-Dec-08 2:35
professionalAbhijit Jana1-Dec-08 2:35 
GeneralRe: How can I retrieve the source code of the content in an iframe. Pin
Dominic Goulet1-Dec-08 3:06
Dominic Goulet1-Dec-08 3:06 
AnswerRe: How can I retrieve the source code of the content in an iframe. Pin
Muhammad Gouda1-Dec-08 4:07
Muhammad Gouda1-Dec-08 4:07 
QuestionRegular expression that rejects empty string. Pin
paper671-Dec-08 1:39
paper671-Dec-08 1:39 
AnswerRe: Regular expression that rejects empty string. Pin
Brij1-Dec-08 1:51
mentorBrij1-Dec-08 1:51 
Questionhow to create a file list Pin
souravghosh181-Dec-08 1:04
souravghosh181-Dec-08 1:04 
AnswerRe: how to create a file list Pin
Ashfield1-Dec-08 1:21
Ashfield1-Dec-08 1:21 
QuestionSending email error on server Pin
zumty1-Dec-08 1:01
zumty1-Dec-08 1:01 
AnswerRe: Sending email error on server Pin
Muhammad Gouda1-Dec-08 3:43
Muhammad Gouda1-Dec-08 3:43 
QuestionAlign the UpdateProgress loading image to the button clicked Pin
playout1-Dec-08 0:36
playout1-Dec-08 0:36 
QuestionMaster Page Sharing In Applications Pin
ALAQUNAIBI30-Nov-08 23:19
ALAQUNAIBI30-Nov-08 23:19 
AnswerRe: Master Page Sharing In Applications Pin
SUDHAKAR PALLAM30-Nov-08 23:24
SUDHAKAR PALLAM30-Nov-08 23:24 
GeneralRe: Master Page Sharing In Applications Pin
ALAQUNAIBI30-Nov-08 23:32
ALAQUNAIBI30-Nov-08 23:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.