By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,058 Members | 1,336 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,058 IT Pros & Developers. It's quick & easy.

How do i connect a VB 6.0 Form to an Access database

P: 8
hello,

What are the steps that i should perform or what is the piece of code that i should use to connect an access database to a VB 6.0 Form? What is the piece of code for inserting , deleting viewing, editing data in the database? Where should i put the code?

Thanks
Nov 28 '06 #1
Share this Question
Share on Google+
1 Reply


P: 5
hello,

What are the steps that i should perform or what is the piece of code that i should use to connect an access database to a VB 6.0 Form? What is the piece of code for inserting , deleting viewing, editing data in the database? Where should i put the code?

Thanks

u got 2 option
1. using ado data control
2. using coding

using adodc
1. add a adodc
2. in the properties change
connect = Access
databasename = 'find the access file'
recordsource = 'the name of the table that want to link'
3. if want to link with the text box, in the change the properties
datasourse = 'the name of the adodc'
datafield = ' the field in the table that want to link'
4. coding of adding new records
Expand|Select|Wrap|Line Numbers
  1. data1.recordset.AddNew
5. coding of delete
Expand|Select|Wrap|Line Numbers
  1. data1.recordset.delete
6. coding of edit
Expand|Select|Wrap|Line Numbers
  1. data1.recordset.edit
7. coding of update
Expand|Select|Wrap|Line Numbers
  1. data1.recordset.update
8. coding of cancel update
Expand|Select|Wrap|Line Numbers
  1. data1.recordset.cancelupdate
9. move data or record
Expand|Select|Wrap|Line Numbers
  1. data1.recordset.movenext
  2.     data1.recordset.movefirst

using coding
try use this coding the different of other action is in SQL only

Expand|Select|Wrap|Line Numbers
  1. Dim con As New ADODB.Connection
  2. Dim con_string As String
  3. Dim sql As String
  4. Dim rs As New ADODB.Recordset
  5. con_string = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = " & App.Path & "\" & "abc.mdb;"
  6. con.Open con_string
  7.  
  8. sql = "select * from test where matrik = 123"
  9. Set rs = con.Execute(sql)
hope it help

-Sky86
Nov 28 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.