none
C# Insert TextBox text into MS Database RRS feed

  • Question

  • Hi I have a MS Database called Holidays with 2 tables called: Destination and Booking.
    I have a web form consisting of:
    GridView Displaying the data from Destination Table
    Label (Text = Holiday ID) with a TextBox (name = txtHolidayID)
    Label (Text = Your Name) with a TextBox (name = txtName)
    Label (Text = "") and (Name = lblMessage)
    Button (Text = Book) and (Name = btnBook)
    When the User clicks the Book Button the Web form should check whether the txtHolidyID (In this case 1 - 4) is one of the Holiday IDs in the GridView(Destination Table), If not the lblMessage should display saying "Invalid ID" and not save the Data.
    When the User clicks the Book Button and the txtHolidayID is correct (Meaning 1 - 4 in this case), and the txtName is of string, then the holidayID in the TextBox which is from the Destination Table should be saved in the Booking Table along with the Name provided and the lblMessage should display "Booking Successful".

    When the User clicks the Book Button and everything is correct but did not save for some reason the lblMessage should display "Booking Failed".

    I have searched the forum for something similar but I'm not finding it.
    I will add Captures of my Database and Web Form to make things easier to understand.
    Sorry for this rookie question.

    Database Capture

    <a href="https://photos.app.goo.gl/YWtok6PUBf598sJw7">Shared album - Dreyer Vorster - Google Photos</a>[<a href="https://photos.app.goo.gl/YWtok6PUBf598sJw7" target="_blank" title="New Window">^</a>]

    Destination Table Capture

    <a href="https://photos.app.goo.gl/yBLR2Fe4gP8G7TCt7">Shared album - Dreyer Vorster - Google Photos</a>[<a href="https://photos.app.goo.gl/yBLR2Fe4gP8G7TCt7" target="_blank" title="New Window">^</a>]

    Booking Table Capture

    <a href="https://photos.app.goo.gl/H1qKuETnbaDLrB8s8">Shared album - Dreyer Vorster - Google Photos</a>[<a href="https://photos.app.goo.gl/H1qKuETnbaDLrB8s8" target="_blank" title="New Window">^</a>]

    WebForm Capture

    <a href="https://photos.app.goo.gl/cyNjYfo1u2qvpeJF8">Shared album - Dreyer Vorster - Google Photos</a>[<a href="https://photos.app.goo.gl/cyNjYfo1u2qvpeJF8" target="_blank" title="New Window">^</a>]

    WebForm with Details Capture

    <a href="https://photos.app.goo.gl/KJ5TCZ4Bp3sHaJAPA">Shared album - Dreyer Vorster - Google Photos</a>[<a href="https://photos.app.goo.gl/KJ5TCZ4Bp3sHaJAPA" target="_blank" title="New Window">^</a>]

    Wednesday, September 18, 2019 8:49 PM

All replies

  • Please clean up your links as they are no good currently.

    This

    <a href="https://photos.app.goo.gl/KJ5TCZ4Bp3sHaJAPA">Shared album - Dreyer Vorster - Google Photos</a>[<a href="https://photos.app.goo.gl/KJ5TCZ4Bp3sHaJAPA" target="_blank" title="New Window">^</a>]

    Should be

    Shared album - Dreyer Vorster - Google Photos


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Wednesday, September 18, 2019 9:32 PM
    Moderator
  • I am trying to edit and repost but it is flagged as spam so I don't understand

    Wednesday, September 18, 2019 10:50 PM
  • When you say "MS Database", what you really have is an "Access Database".  That makes a difference.  Microsoft makes several database products, all different.

    Do you have any code at all yet?  What you've asked for here is rather straightforward.  You've practically written pseudocode in your very detailed description of the problem.  You just need to translate it to C#.  Do you have much C# experience?  You'll have an event handler for the "Book" button click.  It will fetch the value of the txtHolidayID field and do a lookup from the database.  Just do it step by step.


    Tim Roberts | Driver MVP Emeritus | Providenza &amp; Boekelheide, Inc.

    Thursday, September 19, 2019 12:17 AM