Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Working with VB 6.0 and access 2000.

Status
Not open for further replies.

sammmy

IS-IT--Management
May 13, 2008
1
KE
Hello there
I need somebody who can give me a code where i can learn how to connect to a access 2000 database using vb6.I am new into visual basic so i will be needing a simple code with basic insertion,deletion and viewing of database records.Any help will be greatly appreciated.
thanx
Sam
 
You have a database name db1. A table Category(categorycode,CategoryName)in db1 also.
Public cn As New ADODB.Connection

'For connection
Public Sub dbconnect()
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=false;Data Source=" & App.Path & "\db1.mdb"
End Sub
'insert within command1_click
cn.Execute " INSERT INTO Category " _
& "(CategoryCode,CategoryName) VALUES " _
& "('" & txtCatgCode.Text & "','" & Trim(txtCatgName.Text) & "'" & ")"

'for datamodification within command2_click

cn.Execute "UPDATE Category SET Categoryname='" & Trim(txtCatgName.Text) & "' where categorycode='" & Trim(txtCatgCode.Text) & "'"

'for deletion within command3_click

cn.Execute "DELETE * FROM " _
& "category WHERE categorycode ='" & txtCatgCode.Text & "'"

This may the starting point I think. You can get help from MSDN and other books for your development.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top