Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6568849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:33:12+00:00 2026-05-25T14:33:12+00:00

hi I have method for getting the values form database and representing those values

  • 0

hi I have method for getting the values form database and representing those values in chart controls..

and this is the method…

      public static void Hourlyattendence(System.DateTime startdate, System.DateTime enddate, string StartHour, string EndHour,
                                           out string[] Hours, out int[] Accepted, out int[] Refused)
     {
         int hours = 1 + int.Parse(EndHour) - int.Parse(StartHour);

         Hours = new string[hours];
         Accepted = new int[hours];
         Refused = new int[hours];

         int result = 0;

         for (int i = 0; i < hours; i++)
         {
             Accepted[i] = 0;
             Refused[i] = 0;
             Hours[i] = string.Format("{0:00}", int.Parse(StartHour) + i);
         }

         const string sql = @"SELECT COUNT('x') AS numVisits, visit_Status as Status, SUBSTRING(visit_Time,1,2) as visitHour
                              FROM visits
                              WHERE visit_Date BETWEEN @startdate AND @enddate
                              AND SUBSTRING(visit_Time,1,2) between @StartHour and @EndHour
                              GROUP BY SUBSTRING(visit_Time,1,2), visit_Status";

         var hourstable = new DataTable();

         using (var conn = new MySql.Data.MySqlClient.MySqlConnection(connectionstring))
         {
             conn.Open();

             var cmd = new MySql.Data.MySqlClient.MySqlCommand(sql, conn);

             var ds = new DataSet();
             var parameter = new MySql.Data.MySqlClient.MySqlParameter("@startdate", MySql.Data.MySqlClient.MySqlDbType.DateTime);
             parameter.Direction = ParameterDirection.Input;
             parameter.Value = startdate;
             cmd.Parameters.Add(parameter);

             var parameter2 = new MySql.Data.MySqlClient.MySqlParameter("@enddate", MySql.Data.MySqlClient.MySqlDbType.DateTime);
             parameter2.Direction = ParameterDirection.Input;
             parameter2.Value = enddate;
             cmd.Parameters.Add(parameter2);

             var parameter3 = new MySql.Data.MySqlClient.MySqlParameter("@StartHour", MySql.Data.MySqlClient.MySqlDbType.DateTime);
             parameter3.Direction = ParameterDirection.Input;
             parameter3.Value = StartHour;
             cmd.Parameters.Add(parameter3);

             var parameter4 = new MySql.Data.MySqlClient.MySqlParameter("@EndHour", MySql.Data.MySqlClient.MySqlDbType.DateTime);
             parameter4.Direction = ParameterDirection.Input;
             parameter4.Value = EndHour;
             cmd.Parameters.Add(parameter4);

             var da = new MySql.Data.MySqlClient.MySqlDataAdapter(cmd);

             da.Fill(ds);
             try
             {
                 hourstable = ds.Tables[0];

             }
             catch
             {
                 hourstable = null;
             }
         }
         if (hourstable != null)
         {
             for (int i = 0; i < hourstable.Rows.Count; i++)
             {
                 if (int.TryParse(hourstable.Rows[i]["numVisits"].ToString(), out result) && int.TryParse(hourstable.Rows[i]["visitHour"].ToString(), out hours))
                 {
                     hours -= int.Parse(StartHour);
                     if (hourstable.Rows[i]["Status"].ToString().ToUpper() == "ACCEPTED")
                     {
                         Accepted[hours] = result;
                     }
                     else
                     {
                         Refused[hours] = result;
                     }
                 }

             }

         }

     }

and i am calling above method in the below code …and this is where i am representing the data in chart controls….

    private void KpiHourlAttendenceForm_Load(object sender, EventArgs e)
    {
        Drawkpihourlyattendence(dtpStartDate.Value, dtpEnddate.Value);
    }

    public void Drawkpihourlyattendence(DateTime startdate, DateTime enddate)
    {
        try
        {
            KpiHourlyattaendencechart.Series.Clear();

            Series acceptedSeries = KpiHourlyattaendencechart.Series.Add("Accepted");
            Series rejectedSeries = KpiHourlyattaendencechart.Series.Add("Refused");

            string[] xValues;
            int[] yValues;
            int[] yValues2;

            KpiData.Hourlyattendence(startdate, enddate, "06", "22", out xValues, out yValues, out yValues2);

            //blah
           //blah
           ///blah
       }
       catch(FormatException e)
      {
            Console.WriteLine(e.Message);

       }    

got the exception : format Exception String was not recognized as a valid DateTime.

would any one pls help on this…..

Many Thanks in advance…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:33:13+00:00Added an answer on May 25, 2026 at 2:33 pm

    I think you have to change the parameter type for @StartHour and @EndHour because they are string.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having trouble getting the page to work. I have my form method
I have a problem where a method is getting an undefined variable error, even
I have an extension method on the HttpApplicationState object for getting my IoC container
I have a method which takes params object[] such as: void Foo(params object[] items)
I have this method on a webpart: private IFilterData _filterData = null; [ConnectionConsumer(Filter Data
I have a form in index.php <?php echo '<form action=update_act.php method=POST>'; echo '<input type=submit
I am getting this error when I try to set a mock to have
I have an MVC view with a form built with the Ajax.BeginForm() helper method,
I have method in a class that I need to make sure is only
I have class method that returns a list of employees that I can iterate

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.