Save items to Database and get from datagrid
-
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
-
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
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?
जय हिंद
-
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
u should use command builder to save or update which will generate command dynamically insert for new and updated for existance.
-
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?
जय हिंद
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
-
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