Click here to Skip to main content
15,888,579 members
Home / Discussions / ASP.NET
   

ASP.NET

 
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 
AnswerRe: Browser link to a spreadsheet Pin
r a m e s h3-Sep-09 21:05
r a m e s h3-Sep-09 21:05 
GeneralRe: Browser link to a spreadsheet Pin
Mycroft Holmes3-Sep-09 21:14
professionalMycroft Holmes3-Sep-09 21:14 
GeneralRe: Browser link to a spreadsheet Pin
N a v a n e e t h3-Sep-09 21:50
N a v a n e e t h3-Sep-09 21:50 
GeneralRe: Browser link to a spreadsheet Pin
Mycroft Holmes3-Sep-09 22:31
professionalMycroft Holmes3-Sep-09 22:31 
QuestionValidation for dropdown Pin
rummer3-Sep-09 19:52
rummer3-Sep-09 19:52 
AnswerRe: Validation for dropdown Pin
Sachin Dubey3-Sep-09 19:57
Sachin Dubey3-Sep-09 19:57 
AnswerRe: Validation for dropdown Pin
Arun Jacob3-Sep-09 19:58
Arun Jacob3-Sep-09 19:58 
JokeRe: Validation for dropdown [modified] Pin
Arun Jacob3-Sep-09 20:03
Arun Jacob3-Sep-09 20:03 
AnswerRe: Validation for dropdown Pin
N a v a n e e t h3-Sep-09 20:32
N a v a n e e t h3-Sep-09 20:32 
GeneralRe: Validation for dropdown Pin
deepseeindeepsy3-Sep-09 21:52
deepseeindeepsy3-Sep-09 21:52 
GeneralRe: Validation for dropdown Pin
N a v a n e e t h3-Sep-09 22:08
N a v a n e e t h3-Sep-09 22:08 

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.