Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > How to add/update/delete Data from Form1.TextBoxes to DGV in Form2 (VB.Net 2005 with MS-Access 2007)
 

How to add/update/delete Data from Form1.TextBoxes to DGV in Form2 (VB.Net 2005 with MS-Access 2007)

Hi there

Im using VB.Net 2005 with MS-Access 2007 Appln.

The problem is:

In my appln i'm using two forms, among which Form1 contains two textBoxes for prodId and for prodName. and 1 button (used to insert data)

In Form2 I'm using a DataGridView and 2 buttons (Update and Delete)..

Now if I enter the data in Form1 TextBoxes, it should be inserted into my Product table.

And In form2 i should view all the inserted records in DataGridView.... In DGV if i select a row and if I Click Edit button it should Open Form1 with TextBoxes Containing the selected Record data.. and I should Modify the textboxes and by clicking OK it should get updated in my Product table.

Similar manner for Delete also.

I've tried this in many approaches but I didnt get a solution.

The main problem I faced is I'm able to Add Records without DGV, but if I use DGV in FORM2, my connection could not be opened..

Since I'm a beginner I dont know much about DGV and its related functions....

  • Moved byVMazurMVPWednesday, September 30, 2009 10:51 AM (From:ADO.NET Data Providers)
  •  
JCel  Sunday, September 27, 2009 6:05 AM

Hi JCel,

You can use command to update to database manually. This MSDN document will tell you how use oledbcommand for Access database,

http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbcommand(VS.71).aspx

For connect string, you can refer to this URL,

http://www.connectionstrings.com/sql-server-2005#111

For insert, update, delete command,

http://www.w3schools.com/SQL/sql_insert.asp

http://www.w3schools.com/SQl/sql_update.asp

http://www.w3schools.com/Sql/sql_delete.asp

Does this works for you? If you have any questions or concerns, please update the thread and we will have a further discussion.

Best Regards

Yichun Feng


Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Yichun_Feng  Tuesday, September 29, 2009 6:27 AM

You are filling the grid from db table and trying to edit and save the grid data.

Use the code present in below link which helps to solve your issue of edit and save the grid values.

http://www.codeproject.com/KB/vb/DataGridViewEditForm.aspx

Rohini Chavakula  Tuesday, September 29, 2009 12:00 PM

Hi JCel,

You can use command to update to database manually. This MSDN document will tell you how use oledbcommand for Access database,

http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbcommand(VS.71).aspx

For connect string, you can refer to this URL,

http://www.connectionstrings.com/sql-server-2005#111

For insert, update, delete command,

http://www.w3schools.com/SQL/sql_insert.asp

http://www.w3schools.com/SQl/sql_update.asp

http://www.w3schools.com/Sql/sql_delete.asp

Does this works for you? If you have any questions or concerns, please update the thread and we will have a further discussion.

Best Regards

Yichun Feng


Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Yichun_Feng  Tuesday, September 29, 2009 6:27 AM

You are filling the grid from db table and trying to edit and save the grid data.

Use the code present in below link which helps to solve your issue of edit and save the grid values.

http://www.codeproject.com/KB/vb/DataGridViewEditForm.aspx

Rohini Chavakula  Tuesday, September 29, 2009 12:00 PM

You can use google to search for other answers

Custom Search

More Threads

• VB.NET multiple selections in DataGrid
• Flickering question
• Problem with SQL Query and Datetime
• Best Practice - How to populate combobox dropdown lists from the same datatable
• Losing data when binding to a Combo Box control
• cannot find table 0
• Parsing values from a child form to a parent form
• datagrid cell by cell validation
• C# and Crystal report creating a report
• CellDoubleClick on DataGridView