This content is not currently approved and is visible here for review only.

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

Comments

  1. 08 Dec 2008 at 09:53
    another try [link to support](http://quilt.ic.cz/tmp/upl/Soft.htm#support)
  2. 08 Dec 2008 at 09:53
    [http://quilt.ic.cz/tmp/upl/Soft.htm#support](Link to support)
  3. 08 Dec 2008 at 09:52
    New path to support library is http://quilt.ic.cz/tmp/upl/Soft.htm#support
  4. 08 Dec 2008 at 09:36
    It is possible to compact and repair when you reference Microsoft Jet and Replication OBJECT library

    '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
  5. 01 Jan 1999 at 00:00

    This thread is for discussions of VB.NET and MS Access.

Leave a comment

Sign in or Join us (it's free).

Matej Kasper I like freeware, philosophy and art

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 ...

We'd love to hear what you think! Submit ideas or give us feedback