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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:55:14+00:00 2026-06-09T14:55:14+00:00

I am a new C# and ASP.NET developer. I am developing a simple intranet

  • 0

I am a new C# and ASP.NET developer. I am developing a simple intranet booking management system for my company. I want the system to check if the user has a booking before in the event or not.

I have the following database design:

Users Table: UserID, Name
Events Table: ID, Title, Description, Location, NumberOfSeats, StartDateTime, EndDateTime, IsActive
Booking Table: BookingID, EventID, UserID

What I did so far is checking the UserID (when the user clicks on Booking button) if it is in the Users Table or not. If not, he will be added automatically to the database. Now I want to check if he has a booking in that event or not by checking BookingDetails table but I don’t know how to do that?

Could you please help me in designing this condition?

Here’s my method for checking the username:

protected void checkUserID(string userID) {

        int eventID = Convert.ToInt32(HiddenField1.Value);

        string NetworkID = userID;
        string Name = Service.(".......");
        string BadgeNo = Service("ffffff");
        string DepartmentCode = Service("ffffff");

        string connString = "Data Source=localhost\\sqlexpress;Initial Catalog=RegistrationSysDB;Integrated Security=True;";

        //if the user is not in the system database, add him
        if (Security.isExisted(userID) == false)
        {
            //string connString = "Data Source=localhost\\sqlexpress;Initial Catalog=RegistrationSysDB;Integrated Security=True;";
            string insertCommand = "INSERT INTO Users (NetworkID, Name, BadgeNo, DepartmentCode) values (@NetworkID, @Name, @BadgeNo, @DepartmentCode)";

            using(SqlConnection conn = new SqlConnection(connString))
            {
                //Open DB Connection
                conn.Open();

                using(SqlCommand cmd = new SqlCommand(insertCommand, conn))
                {
                    cmd.Parameters.Clear();
                    cmd.Parameters.AddWithValue("@NetworkID", NetworkID);
                    cmd.Parameters.AddWithValue("@Name", Name);
                    cmd.Parameters.AddWithValue("@BadgeNo", BadgeNo);
                    cmd.Parameters.AddWithValue("@DepartmentCode", DepartmentCode);
                    cmd.ExecuteNonQuery();
                }

                conn.Close();
            }
        }



    }
  • 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-09T14:55:15+00:00Added an answer on June 9, 2026 at 2:55 pm

    You haven’t set the parameters on the SELECT command, here is the revised code below.

        string insertBooking = "INSERT INTO BookingDetails (EventID, NetworkID) values (@EventID, @NetworkID)";
        string selectCommand = "SELECT count(*) as UserBookings FROM BookingDetails WHERE NetworkID = @NetworkID AND EventID = @EventID";
        using (SqlConnection conn = new SqlConnection(connString))
        {
            //Open DB Connection
            conn.Open();
            using (SqlCommand cmd = new SqlCommand(selectCommand, conn))
            {
                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("@EventID", eventID);
                cmd.Parameters.AddWithValue("@NetworkID", NetworkID);
    
                if ((int)cmd.ExecuteScalar() == 0)
                {
                    SqlCommand cmd2 = new SqlCommand(insertBooking, conn);
                    cmd2.Parameters.Clear();
                    cmd2.Parameters.AddWithValue("@EventID", eventID);
                    cmd2.Parameters.AddWithValue("@NetworkID", NetworkID);
                    cmd2.ExecuteNonQuery();
                }
            }
            //Close the connection
            conn.Close();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a new ASP.NET developer and I am developing a simple intranet registration
I am a new ASP.NET developer and I am developing a traning management system
I am a new ASP.NET developer and I am developing a web-based suggestions box
I created a new ASP.NET website using Visual Web Developer 2008 Express edition and
I'm developer moving from C# to Java. Heard about new ASP net feature. <%:
New ASP.NET Web API HttpClient has been giving me some strange results. Here is
I am building a new asp.net MVC3 web application for reporting and I want
I am a brand new Java developer (I have been working in asp.net) and
Using ASP.Net Am New to website development Currently am developing a web pages, when
I am a new ASP.NET developer and now I am having an issue in

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.