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 9074305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T18:36:14+00:00 2026-06-16T18:36:14+00:00

I was doing an appointment function from web site. It can compare the date

  • 0

I was doing an appointment function from web site. It can compare the date & time before create new appointment, if user key in the same date & time is exist in the db, it will pop out messagebox. When I try to insert different date & time which different from db, it give me error.
Error

I getting error on this line :

string dtime = time.ExecuteScalar().ToString();

I have no idea what is wrong with my code, can anyone point me out? Thanks.
This is my code :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Windows.Forms;
public partial class MakeAppointment : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
    string appointmentdate = Convert.ToString(DropDownListDay.Text + "-" + DropDownListMonth.Text + "-" + DropDownListYear.Text);
    string appointmenttime = Convert.ToString(DropDownListHour.Text + ":" + DropDownListMinute.Text + ":" + DropDownListSecond.Text + " " + DropDownListSession.Text);

    SqlConnection con = new SqlConnection("Data Source=USER-PC;Initial Catalog=webservice_database;Integrated Security=True");
    con.Open();
    SqlCommand date = new SqlCommand("Select adate from customer_registration where adate='"+ appointmentdate +"'",con);
    string ddate = date.ExecuteScalar().ToString();
    con.Close();
    if (ddate == appointmentdate)
    {
        con.Open();
        SqlCommand time = new SqlCommand("Select atime from customer_registration where atime='"+ appointmenttime +"'", con);
        string dtime = time.ExecuteScalar().ToString();
        con.Close();

        if (dtime == appointmenttime)
        {
            MessageBox.Show("This appointment is not available. Please choose other date & time.");
        }
}
}
  • 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-06-16T18:36:15+00:00Added an answer on June 16, 2026 at 6:36 pm

    Try this

    using System.Web.UI.WebControls;
    using System.Data.SqlClient;
    using System.Configuration;
    using System.Windows.Forms;
    using System;
    public partial class MakeAppointment : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            string appointmentdate = Convert.ToString(DropDownListDay.Text + "-" + DropDownListMonth.Text + "-" + DropDownListYear.Text);
            string appointmenttime = Convert.ToString(DropDownListHour.Text + ":" + DropDownListMinute.Text + ":" + DropDownListSecond.Text + " " + DropDownListSession.Text);
    
            using (SqlConnection con = new SqlConnection("Data Source=USER-PC;Initial Catalog=webservice_database;Integrated Security=True"))
            {
                con.Open();
                SqlCommand date = new SqlCommand("Select adate from customer_registration where adate='" + appointmentdate + "'", con);
                string ddate = date.ExecuteScalar().ToString();
                if (ddate == appointmentdate)
                {
                    SqlCommand time = new SqlCommand("Select atime from customer_registration where atime='" + appointmenttime + "'", con);
                    var rtime = time.ExecuteScalar();
                    if (rtime != null)
                    {
                        string dtime = rtime.ToString();
    
                        if (dtime == appointmenttime)
                        {
                            MessageBox.Show("This appointment is not available. Please choose other date & time.");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Failed to fetch time from database");
                    }
                }
                con.Close();
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Exchange web services, trying to create a calendar entry in another user's
In Ruby on Rails I'm doing something like: Appointment.find( :first, :conditions => staff_id =
Doing the below will reproduce my problem: New WPF Project Add ListView Name the
I'm doing some data analysis over the judge appointment system in France, and using
Can someone tell me what I am doing wrong in the View for Dropdownlist?
Obviously in outlook, one is able to create an appointment in a public folder
I'm trying to create an appointment scheduler using jQuery (UI), Haml, and Rails. I'm
Rails models come with certain built-in methods like this: Appointment.new Appointment.find(1) How do I
I am building a web app that allows our field staff to create appointments.
Doing following in jQuery: $('#signupbox1').on('click', '#signup1', function() { var str = $('#signupform').serialize(); // make

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.