Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Save items to Database and get from datagrid

Save items to Database and get from datagrid

Scheduled Pinned Locked Moved Visual Basic
databasehelpquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dave McCool
    wrote on last edited by
    #1

    I have been working on a database program with a Access database. I have on one form a datagrid and it has "Employee Table" table on it. Now what I want to happen is if you click on a row and click "Open" button (btnOpen" it fills the information to another form with text boxes like "TxtAdd1" (Address) and so on. Also, I have a save button on the form with the text boxes (Save Form) and what I want is to be able to save the information in the text boxes as a new employee in Employee Table, but if the employee ID is same as already in the database table, it will say message "This employee ID already exists, would you like to overwrite current employees information?" (Yes or no) Any help would be appreciated. I am trying to make this so I don't have to use databound items on text boxesThanks in advance.

    In the end we're all just the same

    D A 2 Replies Last reply
    0
    • D Dave McCool

      I have been working on a database program with a Access database. I have on one form a datagrid and it has "Employee Table" table on it. Now what I want to happen is if you click on a row and click "Open" button (btnOpen" it fills the information to another form with text boxes like "TxtAdd1" (Address) and so on. Also, I have a save button on the form with the text boxes (Save Form) and what I want is to be able to save the information in the text boxes as a new employee in Employee Table, but if the employee ID is same as already in the database table, it will say message "This employee ID already exists, would you like to overwrite current employees information?" (Yes or no) Any help would be appreciated. I am trying to make this so I don't have to use databound items on text boxesThanks in advance.

      In the end we're all just the same

      D Offline
      D Offline
      dan sh
      wrote on last edited by
      #2

      You need to write code in the button click events of both the buttons. In case of open, get the selected row and fill its data in the textboxes. In case of save button, use classes in OleDB namespace to save data.

      Dave McCool wrote:

      "This employee ID already exists, would you like to overwrite current employees information?" (Yes or no)

      Assuming this will be the primary key, it should be auto-incremental or should be generated through code. Why are you letting user create the IDs?

      जय हिंद

      D 1 Reply Last reply
      0
      • D Dave McCool

        I have been working on a database program with a Access database. I have on one form a datagrid and it has "Employee Table" table on it. Now what I want to happen is if you click on a row and click "Open" button (btnOpen" it fills the information to another form with text boxes like "TxtAdd1" (Address) and so on. Also, I have a save button on the form with the text boxes (Save Form) and what I want is to be able to save the information in the text boxes as a new employee in Employee Table, but if the employee ID is same as already in the database table, it will say message "This employee ID already exists, would you like to overwrite current employees information?" (Yes or no) Any help would be appreciated. I am trying to make this so I don't have to use databound items on text boxesThanks in advance.

        In the end we're all just the same

        A Offline
        A Offline
        anup keshari
        wrote on last edited by
        #3

        u should use command builder to save or update which will generate command dynamically insert for new and updated for existance.

        1 Reply Last reply
        0
        • D dan sh

          You need to write code in the button click events of both the buttons. In case of open, get the selected row and fill its data in the textboxes. In case of save button, use classes in OleDB namespace to save data.

          Dave McCool wrote:

          "This employee ID already exists, would you like to overwrite current employees information?" (Yes or no)

          Assuming this will be the primary key, it should be auto-incremental or should be generated through code. Why are you letting user create the IDs?

          जय हिंद

          D Offline
          D Offline
          Dave McCool
          wrote on last edited by
          #4

          I fixed that, just realised the ID should be an autonumber. Anyway is there a way of adding the information on all the textboxes to the database table as a new user... the txtAdd1 text will be stored in Address 1 cell and so on.

          In the end we're all just the same

          D 1 Reply Last reply
          0
          • D Dave McCool

            I fixed that, just realised the ID should be an autonumber. Anyway is there a way of adding the information on all the textboxes to the database table as a new user... the txtAdd1 text will be stored in Address 1 cell and so on.

            In the end we're all just the same

            D Offline
            D Offline
            dan sh
            wrote on last edited by
            #5

            Create a stored procedure in your database and send the textbox values as parameters or build a query in your code and perform insert/update using Command object.

            जय हिंद

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups