Click here to Skip to main content
15,913,408 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Gridview Button problem [modified] Pin
sashidhar4-Sep-09 2:17
sashidhar4-Sep-09 2:17 
Question<font> tag become obsolete</font> Pin
myinstincts4-Sep-09 1:40
myinstincts4-Sep-09 1:40 
AnswerRe: tag become obsolete Pin
myinstincts4-Sep-09 1:46
myinstincts4-Sep-09 1:46 
AnswerRe: tag become obsolete Pin
Not Active4-Sep-09 2:15
mentorNot Active4-Sep-09 2:15 
Questioni want create application like outlook or Thunderbird Pin
manish.m.meshram3-Sep-09 23:56
manish.m.meshram3-Sep-09 23:56 
AnswerRe: i want create application like outlook or Thunderbird Pin
Arun Jacob4-Sep-09 0:03
Arun Jacob4-Sep-09 0:03 
AnswerRe: i want create application like outlook or Thunderbird Pin
Ashfield4-Sep-09 1:28
Ashfield4-Sep-09 1:28 
Questionget the bitmap output of the controls Pin
behnam-s3-Sep-09 23:47
behnam-s3-Sep-09 23:47 
AnswerRe: get the bitmap output of the controls [modified] Pin
sashidhar4-Sep-09 1:09
sashidhar4-Sep-09 1:09 
QuestionServer to Server Communication Pin
janat_Al_donia3-Sep-09 22:07
janat_Al_donia3-Sep-09 22:07 
AnswerRe: Server to Server Communication Pin
N a v a n e e t h3-Sep-09 22:13
N a v a n e e t h3-Sep-09 22:13 
GeneralRe: Server to Server Communication Pin
Arun Jacob3-Sep-09 22:31
Arun Jacob3-Sep-09 22:31 
Questionadding data Pin
ankitjain11103-Sep-09 21:24
ankitjain11103-Sep-09 21:24 
AnswerRe: adding data Pin
Vimalsoft(Pty) Ltd3-Sep-09 21:29
professionalVimalsoft(Pty) Ltd3-Sep-09 21:29 
GeneralRe: adding data Pin
ankitjain11103-Sep-09 21:33
ankitjain11103-Sep-09 21:33 
GeneralRe: adding data Pin
Blue_Boy3-Sep-09 21:37
Blue_Boy3-Sep-09 21:37 
GeneralRe: adding data Pin
ankitjain11103-Sep-09 21:52
ankitjain11103-Sep-09 21:52 
GeneralRe: adding data Pin
Vimalsoft(Pty) Ltd3-Sep-09 22:24
professionalVimalsoft(Pty) Ltd3-Sep-09 22:24 
AnswerRe: adding data Pin
N a v a n e e t h3-Sep-09 22:07
N a v a n e e t h3-Sep-09 22:07 
What a load of crap! Seriously, you code is flawed.

You don't need a for loop here. Add 7 days to the date and have only one query. Also just for displaying to grid, you don't need a DataSet. A simple reader should do. Here is the code with some improvements.
C#
// use some meaningful names
string connectionString = ConfigurationManager.AppSettings["conn"];

// use parameterized queries to avoid SQL injection
// query altered to avoid unnecessary looping
string query = "select * from appointment where DATE >= @StartDate and DATE <= @EndDate";

// wrap the connection and command in using block to avoid resource leaks.
using(OleDbConnection connection = new OleDbConnection(connectionString))
using(OleDbCommand command = new OleDbCommand(query, connection);
{
    command.Parameters.AddWithValue("@StartDate", selectedDate.ToShortDateString());
    command.Parameters.AddWithValue("@EndDate", selectedDate.AddDays(7).ToShortDateString());

    connection.Open();
    // using a reader. You don't need a dataset as you are not persisting it in memory
    using(OleDbDataReader reader = command.ExecuteReader())
    {
        GridView1.DataSource = reader;
        GridView1.DataBind();        
    }
    connection.Close();
}
Note: Code written directly on CP editor. You may need to correct some compilation errors.

Smile | :)


QuestionHow to authenticate with Active Directory? Pin
baburman3-Sep-09 21:18
baburman3-Sep-09 21:18 
AnswerRe: How to authenticate with Active Directory? Pin
Arun Jacob3-Sep-09 22:38
Arun Jacob3-Sep-09 22:38 
GeneralRe: How to authenticate with Active Directory? Pin
baburman4-Sep-09 1:44
baburman4-Sep-09 1:44 
GeneralBrowser link to a spreadsheet Pin
Mycroft Holmes3-Sep-09 20:06
professionalMycroft Holmes3-Sep-09 20:06 
GeneralRe: Browser link to a spreadsheet Pin
N a v a n e e t h3-Sep-09 20:37
N a v a n e e t h3-Sep-09 20:37 
GeneralRe: Browser link to a spreadsheet Pin
Mycroft Holmes3-Sep-09 20:58
professionalMycroft Holmes3-Sep-09 20:58 

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.