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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:46:58+00:00 2026-06-18T12:46:58+00:00

I have a problem where I am unable to make a booking to a

  • 0

I have a problem where I am unable to make a booking to a Sql server .mdf database, but I am able to read to it.

No error messages occur and I have tried everything I can think of. Any help will be highly appreciated and thanks in advance!
Here is the code used for the insert into command:

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

    Dim SQLCode As New SQLCode
    Dim con As New SqlConnection
    Dim cmd As New SqlCommand
    Dim lrd As SqlDataReader
    Dim inscmd As New SqlCommand

    cmd.Parameters.AddWithValue("@StaffInitials", lblStaffInitials.Text.Trim())
    lblStaffInitials.Text = lblStaffInitials.Text
    cmd.Parameters.AddWithValue("@Week", lblWeek.Text.Trim)
    lblWeek.Text = lblWeek.Text
    cmd.Parameters.AddWithValue("@Period", (lblPeriod.Text.Trim))
    lblPeriod.Text = lblPeriod.Text
    cmd.Parameters.AddWithValue("@Day", lblDay.Text.Trim)
    lblDay.Text = lblDay.Text
    cmd.Parameters.AddWithValue("@Subject", lblSubject.Text.Trim)
    lblSubject.Text = lblSubject.Text
    cmd.Parameters.AddWithValue("@YearGroup", lblYear.Text.Trim)
    lblYear.Text = lblYear.Text
    cmd.Parameters.AddWithValue("@NumberOfPupils", (lblNoOfPupils.Text.Trim))
    lblNoOfPupils.Text = lblNoOfPupils.Text
    cmd.Parameters.AddWithValue("@ControlledAssesment", lblControlledAssesment.Text.Trim)
    lblControlledAssesment.Text = lblControlledAssesment.Text
    cmd.Parameters.AddWithValue("@Room", lblRoom.Text.Trim)
    lblRoom.Text = lblRoom.Text
    cmd.Parameters.AddWithValue("@Session", txtSession.Text.Trim)
    txtSession.Text = txtSession.Text

con.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("RoomBookingSystem.My.MySettings.Database1ConnectionString1").ConnectionString
    Try
        Using cn As New SqlConnection(con.ConnectionString)
            con.Open()
            inscmd.CommandText = "INSERT INTO Booking (Week, Day, Period, Subject, YearGroup, StaffInitials,NumberOfPupils,Session,Room,ControlledAssesment) VALUES (@Week,@Day,@Period,@Subject,@YearGroup,@StaffInitials, @NumberOfPupils,@Session,@Room,@ControlledAssesment)"
            inscmd.Connection = con
            inscmd.ExecuteNonQuery()
            inscmd.Parameters.Clear()
        End Using

    Finally
        con.Close()
    End Try
    MsgBox("Your Booking Has Been Made Successfully")
    Clicky = False
    MainViewForm.btnBackToBooking.Visible = False
    FormView.Show()
    Me.Hide()
End Sub
  • 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-18T12:46:59+00:00Added an answer on June 18, 2026 at 12:46 pm

    As far as I can tell the problem lies within the databases location.

    When the program is debugged a copy of your database is placed within the bin/debug folder, if you look in here you will see the copy and your code will right to this database and Not The original Database (if you click show all files then go to the bin/debug file and then open with database explorer you can see the data imputed on the last debug/running)

    To fix this you need to do the following:

    Your connection string

     con.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("RoomBookingSystem.My.MySettings.Database1ConnectionString1").ConnectionString
    

    Will connect to the database within the bin folder mentioned previously.

    You need to go into your app.config file find the specific location for your database and use this for you connection string, this will allow you to insert/update data from the non copy of the database.

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

Sidebar

Related Questions

I have a problem with parseInt() , it throws the error: unable to parse
I have been unable to figure out this problem - it just doesn't make
I use twitter4j library to make somethings with twitter. But i have a problem
I have problem SIMILAR to preventing form data reposting, but not quite the same
I have posted my problem at http://jsfiddle.net/ugnf4/ as it would be make it easier.
I have a problem, I want insert data with a button click method, but
I have a simple problem, yet i am unable to solve this. Either my
So I have a compiled and running Siphon app but it just won't make
I have a tough problem. I want to make a .dll that is netload-ed
I have a problem I am unable to solve even though I spend long

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.