| | |
view and edit data from database
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: May 2006
Posts: 13
Reputation:
Solved Threads: 0
email me at khanayub_chand@yahoo.com
•
•
Join Date: Jun 2006
Posts: 1
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by ezajan
hi,sir,
i woul dlike to view the data from the database n edit them.but i dont know the coding..sir,please help me sir..i m developing the system using window based.thank you
http://www.tampier.de
Hi
The way i do it is adding a datagrid to the form, then connect to the database using a oleDBconnection connection and get the dataset. Then create a dataview and set its source as the table you want to display from the dataset.
then set the dataview as the datasource of the datagrid, and that should do it.
When you close the form, make sure to check if the dataset has changes and update if necessary.
Here is the code:
regards
The way i do it is adding a datagrid to the form, then connect to the database using a oleDBconnection connection and get the dataset. Then create a dataview and set its source as the table you want to display from the dataset.
then set the dataview as the datasource of the datagrid, and that should do it.
When you close the form, make sure to check if the dataset has changes and update if necessary.
Here is the code:
VB.NET Syntax (Toggle Plain Text)
Private con As OleDbConnection = New OleDbConnection Private comd As OleDbCommand = New OleDbCommand("SELECT * FROM Table", con) Private dst As DataSet = New DataSet Private dvw As DataView = New DataView sub populate_datagrid() con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & database_file & ";Mode=Read|Write" comd.CommandTimeout = 30 ' oledbcommand dap.SelectCommand = comd ' data adapter dst.Clear() ' clear the data set dap.TableMappings.Clear() 'clear the data_adapter before using it dap.TableMappings.Add("Table", "Table_name") dap.Fill(dst, "Table_name") dvw.Table = dst.Tables(0) dvw.RowFilter = Nothing Me.datagrid1.DataSource = dvw End sub
regards
![]() |
Similar Threads
- Insert & Edit Data in DataGrid (VB.NET)
- retrieving a single cell of data from a MySQL database (PHP)
- How to store data in data grid to database by single mouse click in Asp.net (ASP.NET)
- copy data from excel to vb database (Visual Basic 4 / 5 / 6)
- Inserting Data into Access Database (Java)
- Posting form data to an Oracle database (JavaScript / DHTML / AJAX)
- IE doesn't open in a new window, help! (Windows 95 / 98 / Me)
Other Threads in the VB.NET Forum
- Previous Thread: Search Results not displayed in Firefox/Safari
- Next Thread: whats wrong in this
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2008 access add advanced application array assignment basic binary box button buttons center click code combo connectionstring convert cpu data database databasesearch datagrid datagridview design designer dissertation dissertations dissertationthesis dosconsolevb.net editvb.net employees excel exists firewall folder forms image images isnumericfuntioncall listview login map math memory mobile module msaccess mssqlbackend mysql navigate net number opacity pan peertopeervideostreaming picturebox picturebox2 port print printpreview record regex reports" reuse right-to-left save savedialog search serial socket sqldatbase sqlserver storedprocedure string temp textbox timer txttoxmlconverter useraccounts usercontol usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vba vbnet vista visual visualbasic visualbasic.net visualstudio.net web wpf xml





