the_sleeper
asked on
C# Newbie HowTo: Wire a DataSet to a Calendar Control
Greetings,
I have created a dataset of events in a SQL Dbase. (See Code Sample). Now I'm trying to figure out how to wire it to the Calendar Control so as to have matching events display for the correct day. I've been all over the web looking for a good resource. Cant find any.
Please outline the steps I need to take and show a code example (for us "Greenhorns").
thanks
sleeper
I have created a dataset of events in a SQL Dbase. (See Code Sample). Now I'm trying to figure out how to wire it to the Calendar Control so as to have matching events display for the correct day. I've been all over the web looking for a good resource. Cant find any.
Please outline the steps I need to take and show a code example (for us "Greenhorns").
thanks
sleeper
using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Web;
/// <summary>
/// Summary description for calendarDataObject
/// </summary>
public class calendarDataObject
{
// declare method to get events
public DataSet getEvents()
{
// Step 01: Get conn string from web.config
string CalConn = ConfigurationManager.ConnectionStrings["ConnectionString1"].ConnectionString;
// Step 02: Test connection string
if(CalConn != null)
{
// Step 03: Create a SqlConnection object
SqlConnection objConn = new SqlConnection(CalConn);
// Step 04: Create an SQL Query
string qryGetEvents = "SELECT * FROM tbl_events";
// Step 05: Create a SqlDataAdapter
SqlDataAdapter sqlDA_getEvents = new SqlDataAdapter(qryGetEvents,CalConn);
// Step 06: Create a dataset
DataSet dsGetEvents = new DataSet();
// Step 07: Fill dataset
sqlDA_getEvents.Fill(dsGetEvents);
// Step 08: Return dataset
return dsGetEvents;
}
// return null if no connection string present
return null;
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Opps. Obviously that R should have been the DayRow object, found by matching the primary key to the e.Day.Date.
e.Cell.Text = DayRow.Item("columnname").ToString
ASKER
Thanks, GreymanMSC
ASKER
Getting an error stating that the DataSet (dsGetEvents) does not exist in the current context.
Little Help?
Open in new window