Here is some code extracted from one of my programs, it shouldQuote:> Please give insight or sample code on how to connect to an Access 2000
> database & table, then add, edit & delete records in that table using ADO
> coding and not a data control.
> Thanks in advance
Public Sub ModifyTableContents(strTableName As String)
' Display the specified table in the form "frmTableModify"
' inside the DataGrid named "dgrModifyGrid" using
' an Adodc control. This grid allows changes to the
' database.
frmTableModify.lblTableModify.Caption = "Contents of table " & _
strTableName
frmTableModify.adoTableModify.CommandType = adCmdTable
frmTableModify.adoTableModify.RecordSource = strTableName
frmTableModify.adoTableModify.ConnectionString =
"Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;User
ID=Admin;Data Source=c:\somewhere\dbname.mdb;Mode=Share Deny None"
Set frmTableModify.dgrModifyGrid.DataSource =
frmTableModify.adoTableModify
frmTableModify.Show vbModal
Exit Sub
End Sub
"frmTableModify" is a form containing :
datagrid control ("dgrModifyGrid") with the properties
"AllowAddNew" , "AllowDelete" and "AllowDelete"
set to true
Adodc control ( "adoTableModify")
with "BOFAction" set to 0 - adDoMoveFirst
label ("lblTableModify") - this label identifies the table
that is being manipulated by the form
--
---------
Barry Kimelman
Winnipeg, Manitoba, Canada
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
'-- Begin sample code
Dim oCn As New ADODB.Connection
Dim oRs As New ADODB.Recordset
'Open a connection to the Access database
oCn.Open "provider=microsoft.jet.oledb.4.0;data source=c:\northwind.mdb;"
'Open a recordset containing all the rows from the Customers table
oRs.Open "SELECT * FROM CUSTOMERS", oCn
'Add a new row to the recordset
oRs.AddNew
oRs!CustomerID = "12345"
oRs!CompanyName = "My Test Company"
oRs.Update
'Or update a particular row
oRs!CustomerID = "12344"
oRs.Update
'Or delete the row
oRs.Delete
'Now clean up, closing your objects
oRs.Close
oCn.Close
Set oRs = Nothing
Set oCn = Nothing
'-- End sample code
You must add a reference to "ActiveX Data Objects Library 2.5" or later to
your project for this code to work. You also must have Microsoft Data
Access Components 2.5 or later installed on your machine. This will give
you the Jet 4.0 driver that allows you to read Access 2000 and later
databases. If you are working with Access 97 or earlier, you can change the
provider name to "microsoft.jet.oledb.3.5" and use ADO 2.1 if it exists on
your machine.
Hope this helps!
Steven Bras, MCSD
Microsoft Developer Support/Visual Basic WebData
This posting is provided "AS IS" with no warranties, and confers no rights.
Are you secure? For information about the Microsoft Strategic Technology
Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.
source=c:\northwind.mdb;"Quote:> In a nutshell, here's a sample that shows adding, updating and deleting
> rows using an ADODB recordset object:
> '-- Begin sample code
> Dim oCn As New ADODB.Connection
> Dim oRs As New ADODB.Recordset
> 'Open a connection to the Access database
> oCn.Open "provider=microsoft.jet.oledb.4.0;data
Quote:> 'Open a recordset containing all the rows from the Customers table
> oRs.Open "SELECT * FROM CUSTOMERS", oCn
> 'Add a new row to the recordset
> oRs.AddNew
> oRs!CustomerID = "12345"
> oRs!CompanyName = "My Test Company"
> oRs.Update
> 'Or update a particular row
> oRs!CustomerID = "12344"
> oRs.Update
> 'Or delete the row
> oRs.Delete
> 'Now clean up, closing your objects
> oRs.Close
> oCn.Close
> Set oRs = Nothing
> Set oCn = Nothing
> '-- End sample code
> You must add a reference to "ActiveX Data Objects Library 2.5" or later to
> your project for this code to work. You also must have Microsoft Data
> Access Components 2.5 or later installed on your machine. This will give
> you the Jet 4.0 driver that allows you to read Access 2000 and later
> databases. If you are working with Access 97 or earlier, you can change
the
> provider name to "microsoft.jet.oledb.3.5" and use ADO 2.1 if it exists on
> your machine.
> Hope this helps!
> Steven Bras, MCSD
> Microsoft Developer Support/Visual Basic WebData
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> Are you secure? For information about the Microsoft Strategic Technology
> Protection Program and to order your FREE Security Tool Kit, please visit
> http://www.microsoft.com/security.
Steven Bras, MCSD
Microsoft Developer Support/Visual Basic WebData
This posting is provided "AS IS" with no warranties, and confers no rights.
Are you secure? For information about the Microsoft Strategic Technology
Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.
1. Connect to, add, edit, delete records in ACC2000
Please give some insight or sample code on how to connect to an Access 2000
database & table, then add, edit and delete records using VB6 and ADO
connection.
Thanks in advance
2. MFC app. for Oracle on Unix?
3. Can't delete/add records connecting through Access
4. Data Grid Balloon Help Time
5. Adding records vs. Deleting records
6. job openings in d2k and ora
7. Deleting Records and adding records
8. Com Package
9. deleting records in a table and then adding new records
10. Cannot add record to Visual Foxpro table after deleting all records in table
11. Need add/edit/delete component!
12. Need Functioning Example Of DataControl( Must ADD, DELETE, EDIT)
13. Database Edit, Delete, Add etc