NotePage, Inc. Forum Index

Search found 2 matches
NotePage, Inc. Forum Index
Author Message
  Topic: Update Access database
Zack

Replies: 3
Views: 11919

PostForum: General Questions and Announcements   Posted: Wed Mar 28, 2007 5:29 am   Subject: Update Access database
You response confuses me even further?
I originally did a VB related search on Google and was directed to a posting on your site.
I then made the assumption that this site contains a developers forum as well.
If I was mistaken or posted in the wrong area. please let me know.
regards
  Topic: Update Access database
Zack

Replies: 3
Views: 11919

PostForum: General Questions and Announcements   Posted: Tue Mar 27, 2007 12:18 am   Subject: Update Access database
Hi there,
I used to be pretty OK with VB6.
The code I am listing is from a VB2005 app.
I need the code to be added to the bottom to save the changes back to the database.
Thanks a span.

Dim cn As New ADODB.Connection()
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\duratech.mdb"
cn.Open()

Dim rs As New ADODB.Recordset()
rs.CursorLocation = ADODB.CursorLocationEnum.adUseClient
rs.CursorType = ADODB.CursorTypeEnum.adOpenStatic
rs.LockType = ADODB.LockTypeEnum.adLockBatchOptimistic
rs.Open("select * from products", cn)
rs.ActiveConnection = Nothing
cn.Close()

Dim da As New System.Data.OleDb.OleDbDataAdapter()
Dim ds As New DataSet()
da.Fill(ds, rs, "products")
'Dim tt As New DataView
Dim tblAuthors As DataTable
tblAuthors = ds.Tables("products")

Dim drCurrent As DataRow
' Obtain a new DataRow object from the DataTable.
drCurrent = tblAuthors.NewRow()

' Set the DataRow field values as necessary.
drCurrent("productname") = "993-21-3427"
drCurrent("productdescription") = "George"
tblAuthors.Rows.Add(drCurrent)
'drCurrent = tblAuthors.Rows.Find("993-21-3427")
drCurrent.BeginEdit()
drCurrent("productdescription") = "Peter" '& drCurrent("productdescription").ToString.Substring(3)
drCurrent.EndEdit()
 
Page 1 of 1
All times are GMT - 5 Hours
Jump to:  


Powered by phpBB © 2001, 2002 phpBB Group
Theme created by Vjacheslav Trushkin