search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Return specified days from database

Asked by Anonymous
16 years ago.

Hi,

I am using daypilot lite 2.3. I managed to connect the daypilot to my database but all events are rendering on one single day, todays current date. How can I render the events based their own specified days?

Comment posted by Martin R.
16 years ago.
Possibly you didn't retrieve or not bind the date for each even. How does your query and binding look like? Or course you must also set the Calenders properties correctly, something like StartDate and DaysDisplayed or similar..

Greetings,

Martin
Comment posted by Dan Letecky
16 years ago.
Martin is right, it seems that you are binding to a time-only field. The column values specified by DataStartField and DataEndField properties are converted to DateTime using Convert.ToDateTime() method. If you supply just time, current date will be added during the conversion.
Comment posted by Anonymous
16 years ago.

here is how my binding and query looks like...also my DataStartField and DataEndField are bound to data with the date and time are supplied.

protected DataTable GetEventData()
{
SqlConnection myConnection = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["ConnectionString"]);
myConnection.Open();

SqlTransaction myTrans = myConnection.BeginTransaction();

SqlCommand myCommand = new SqlCommand();
myCommand.Connection = myConnection;
myCommand.Transaction = myTrans;
myCommand.CommandText = "Select * From appointment";
myCommand.ExecuteNonQuery();
myTrans.Commit();
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(myCommand);
da.Fill(ds);
myConnection.Close();

Session["EventData"] = ds.Tables[0];

return (DataTable)Session["EventData"];

}

Comment posted by Dan Letecky
16 years ago.
Hi.

1. First, the lines that are commented out are not necessary (SqlDataAdapter.Fill() can open and closes the connection and transaction for you).
It's also not recommended to store the result in Session unless there is a specific reason for that. You can store it in a private field that will be used during a single page load. After page reload (or in another page) you will want to reload the data from the database anyway.
In the examples, Session is used just to emulate the database (to keep the changes during the session duration).

SqlConnection myConnection = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["ConnectionString"]);
//myConnection.Open();
//SqlTransaction myTrans = myConnection.BeginTransaction();
SqlCommand myCommand = new SqlCommand();
myCommand.Connection = myConnection;
//myCommand.Transaction = myTrans;
myCommand.CommandText = "Select * From appointment";
//myCommand.ExecuteNonQuery();
//myTrans.Commit();
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(myCommand);
da.Fill(ds);
//myConnection.Close();

Session["EventData"] = ds.Tables[0];

return (DataTable)Session["EventData"];

2. Can you please post your "appointment" table DDL definition and DayPilot declaration from .aspx file?
Comment posted by Anonymous
16 years ago.

"Appointment Table"

Appt_day application_type appt_IDendDate
Jul 3 2007 9:30AM employment 1Jul 3 2007 9:45AM

<DayPilot:DayPilotCalendar id=DayPilotCalendar1 runat="server" Width="500"
NonBusinessHours="HideIfPossible" TimeFormat="Clock12Hours"
PkColumnName="appt_ID" NameColumnName="last_name"
EndColumnName="endDate" BeginColumnName="appt_time"
HourHeight="80" BusinessEndsHour="12" >

if (!IsPostBack) { DayPilotCalendar1.DataSource = GetEventData();}

Comment posted by Dan Letecky
16 years ago.
You are using BeginColumnName="appt_time" but according to the table sample above it seems it should be BeginColumnName="Appt_day". Would changing it fix the problem?
Comment posted by Anonymous
16 years ago.

No, that does not change anything

Comment posted by Anonymous
16 years ago.

Thanks dan for all your help. Not sure what i did, but seems to work now!

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.