Take the 2-minute tour ×

I have an sql select script that will execute and shows that there is data being selected when it is run. The problem I am having is trying to get that data to show in my calendar control. I wanted to change the calender by what department the user was from that logged in. Right now there is nothing showing and it will not show any data unless I hard code a department in it.

I am working with c# asp.net.

here is what I am doing to try and get the data

        private DataSet GetData()
        var CurrUser = "a73      ";
        var UsrDepartment = "60      ";

        Account.Login uusr = new Account.Login();
        CurrUser = uusr.User.Identity.Name.ToString().ToUpper();

        ConnectionStringSettingsCollection cssc = ConfigurationManager.ConnectionStrings;

        var sql = "select (substring(status, 1,1)) AS stat1, lastname, firstname, ldate, edate,depdivid, requestid from TIME.employee E inner join TIME.request T on E.EMPID = T.empid where E.depdivid =  @UsrDepartment ";

        using (iDB2Connection conn = new iDB2Connection(GetConnectionString()))

            using (iDB2Command cmd = new iDB2Command(sql, conn))

                using (iDB2DataAdapter da = new iDB2DataAdapter(cmd))
                    DataSet ds = new DataSet();

                    return ds;

I fill the calendar with this :

DataSet ds = GetData();    
foreach (DataRow row in ds.Tables[0].Rows)
                    //need to fill from first to last date
                    string scheduledDate = Convert.ToDateTime(row["ldate"]).ToShortDateString();
                    string endDate = Convert.ToDateTime(row["edate"]).ToShortDateString();

                    e.Cell.Width = 120;
                    e.Cell.Height = 100;

                    Int32 start = 0;
                    Int32 end = 0;

                    start = string.CompareOrdinal(scheduledDate, s);
                    end = string.CompareOrdinal(endDate, s);

                    if ((start <= 0) & (end >= 0) & (!e.Day.IsWeekend))
                        HyperLink lb = new HyperLink();
                        lb.Text = link + (Int64)row["requestid"] + "' >" + row["lastname"] + "</a>" as String + "(" + row["stat1"] + ")" as String + "<br />";

                        //code to change color of button
                        if (scheduledDate == endDate)
                            lb.CssClass = "changecolor";

This way will show no links in my calendar, but if I make the department have a value(which is not what I wanted) it will show the links.

share|improve this question
where do you set the value of the parameter ? –  Hugh Jones Oct 18 '12 at 16:06
the table employee has the value depdivid which is the department. I was trying to call the value based on the user login. –  user1596472 Oct 18 '12 at 16:09

1 Answer 1

up vote 1 down vote accepted

I think you need a line like this

cmd.Parameters["@UsrDepartment"].Value = myDept
share|improve this answer

Your Answer


