Library tutorials & articles
VB.NET and MS Access
DataGridView
Because many things changed from DataGrid to DataGridView, I am not very educated in new DataGridView.
Basic Filling DataGridView
DA = New OleDb.OleDbDataAdapter("Select id,name From id_name", con)
DT = New DataTable
DA.Fill(DT)
Me.DataGridView1.DataSource = DT
I put small example how to trace datagrid changes in attached code
Using DataAdapter to commit updates to database
(see GridView tab in demo)
If you preserves DT, and DA somewhere, after filling datagridview, you can use them again to ease your modifications above database according to gridview. [msdn 1, 2]
DA.UpdateCommand = New OleDb.OleDbCommand()
DA.UpdateCommand.Connection = con
DA.UpdateCommand.CommandText = "Update id_name set name=? Where id=?"
DA.UpdateCommand.Parameters.Add("name", OleDb.OleDbType.VarChar, 10, "name")
DA.UpdateCommand.Parameters.Add("oldId", OleDb.OleDbType.Integer, 4, "oldId")
DA.InsertCommand = New OleDb.OleDbCommand
DA.InsertCommand.Connection = con
DA.InsertCommand.CommandText = "Insert Into id_name(id,name) Values(?,?)"
DA.InsertCommand.Parameters.Add("id", OleDb.OleDbType.Integer, 4, "id")
DA.InsertCommand.Parameters.Add("name", OleDb.OleDbType.VarChar, 10, "name")
DA.DeleteCommand = New OleDb.OleDbCommand
DA.DeleteCommand.Connection = con
DA.DeleteCommand.CommandText = "Delete From id_name Where id=?"
DA.DeleteCommand.Parameters.Add("id", OleDb.OleDbType.Integer, 4, "oldId")
DA.Update(dt)
I will welcome and add any linkage to yours DF articles about datagridview, or datagrid.
| sample source code |
Related articles
Related discussion
-
How to Change Default exe Icon in C#.net Windows Application
by sonali.terse (2 replies)
-
Web App Service Project - Assistance Requested
by JusticeV (0 replies)
-
VB.net ms SQL 2005 express :- couldn't enter data into database
by sanjeev58 (0 replies)
-
how to save email into database in xml format to sql format and how to trigger back in html
by shahid123 (0 replies)
-
insert in master table and update in other table
by shahid123 (0 replies)
Related podcasts
-
Rocky Lhotka on Data Access Mania, LINQ and CSLA.NET
Scott talks with developer and author Rockford Lhotka about the attack of the DALs (Data Access Layers). How can we put LINQ to SQL, LINQ to Entities and classic multi-tiered design all into a larger context? What's the right strategy for your data access needs? Scott's got questions and Rocky's ...
'compact Private Sub MenuItem9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem9.Click If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then If IO.File.Exists(ofd.FileName) Then If sfd1.ShowDialog = Windows.Forms.DialogResult.OK Then Dim JRO As New JRO.JetEngine JRO.CompactDatabase("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & ofd.FileName, _ "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sfd1.FileName & ";Jet OLEDB:Engine Type=5") End If End If End If End Sub
This thread is for discussions of VB.NET and MS Access.