Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



How to connect the VB6 with MS Access 2003?

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 14-01-2010
Member
 
Join Date: Dec 2009
Posts: 18
How to connect the VB6 with MS Access 2003?
  

I am beginner in the programming language world(i.e beginner programmer). I am learning language: Core Java, Visual Basic, SQL, ASP and C sharp. In this days, i am doing project in Visual Basic 6 and this project has backend as MS Access. When i was trying to connect both i.e VB6 and MS Access 2003, i got error when i tried to connect between "record source" in VB6 with data that is saved Access. Please tell me how to connect the VB6 project with MS Access 2003.

Reply With Quote
  #2  
Old 14-01-2010
Member
 
Join Date: Jan 2008
Posts: 1,515
Re: How to connect the VB6 with MS Access 2003?

As per my knowledge the Visual Basic 6 is only able to manage the MS Access 97 file formats. So, before connecting the MS Access 2003 file to the VB 6, convert the that Access 2003 file to the Access 97 format, because it supports only the Access 97 files. This converting can be done easily, Goto MS Access 2003-- Open your database file--Tools--Database Utilities--Convert Database --To Access 97 file Format. Once this is done you will not able to do any modification in your file so, take this after completing the modification or create a new access 97 file every time you make changes.
Reply With Quote
  #3  
Old 14-01-2010
Member
 
Join Date: Feb 2008
Posts: 1,846
Re: How to connect the VB6 with MS Access 2003?

To connect Visual Basic 6 to the Ms Access 2003 file, you need to use the DAO or ADO as connection provider to the database. For this, inside Menu, put a click on Microsoft ActiveX Data Objects.
And in your project General Declaration Area, have to write this code:
Dim con As New ADODB.Connection
Dim r1 As New ADODB.Recordset
And in Form's Activate Event
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="your database complete path";Persist Security Info=False"
con.Open
r1.Open " select * from (your database name)", con, adOpenStatic, adLockPessimistic
Hope you will able to understand this code, and can apply in your project.
Reply With Quote
  #4  
Old 14-01-2010
Member
 
Join Date: May 2008
Posts: 2,383
Re: How to connect the VB6 with MS Access 2003?

I would prefer to use the ADO(ActiveX Data Object) to connect VB6 to MS Access file. The ADO is the most basic and simple way to connect to the database. Basic of the connection is as follow:
Dim con As ADODB.Connection, recsource As ADODB.Recordset
Dim strCon as String, str1Sql as String
Set con = New ADODB.Connection
Set recsource = New ADODB.Recordset
strCon = "Provider=Microsoft.Jet.OLEDB.4.0;"& "Persist Security Info=False;"&"Data Source=\\Server\Share\DatabaseName.MDB"
con.Open strCon
str1Sql = "SELECT * FROM Tablename "
recsource.Open str1Sql, con, adOpenKeyset, adLockOptimistic
Hope this code will make you understand how to connect MS Access.
__________________
The FIFA Manager 2009 PC Game
Reply With Quote
  #5  
Old 14-01-2010
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: How to connect the VB6 with MS Access 2003?

I know one of the step to connect the Visual Basic to the MS Access2003, and it goes like this:Goto "Control Panel"--Click on "Performances and Maintenance"--Click on the Administrative tools option--DoubleClick on Data Sources (ODBC)--Note that you watch a dialog box--in that Click System dsn--After that Click on add-- Again DoubleClick Access2003 driver .mdb--Click Select then find the Access2003 database which you saved--then click on OK--In the Data Source Name option type the filename of the Ms Access Database( like db1.mdb)--Click OK. Press enter. Hope this method will allow to use the MS Access2003 files in Visual Basic 6.
Reply With Quote
  #6  
Old 14-01-2010
Member
 
Join Date: May 2008
Posts: 2,007
Re: How to connect the VB6 with MS Access 2003?

According to me you should use either the ADO(ActiveX Data Object) or DAO(Data Access Object). This are the basic and most simple method used to connect VB 6 to the MS Access. The basic code for ADO is as follow:
In general declaration
Dim con as Adodb.connection, rs as Adodb.recordset
Dim sql1 as String, sql2 as String

Private Function Connection()
Set rs = New ADODB.Recordset
Set con = New ADODB.Connection
sql1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" Fullpath of database" & ";Persist Security Info=False"
con.Open (sql1), , , 0
End Function
Call this Connection in which ever form you want the database connection.
Hope you will get solve soon and your project gets complete on time.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to connect the VB6 with MS Access 2003?"
Thread Thread Starter Forum Replies Last Post
XP VPN to SBS 2003 will not connect lbischoff Small Business Server 3 05-11-2011 04:09 AM
Read Access 2003 files with Access 2007 Kendal-J Windows Software 2 26-05-2010 06:57 PM
Connect Windows 7 to SBS 2003 Galiher Small Business Server 2 30-04-2010 07:17 PM
Remote Access and Outlook Web Access on SBS 2003 mannuraama Small Business Server 4 04-06-2008 05:22 AM
ACCESS 2003 TRIAL Suu!Shant MS Office Support 1 31-05-2007 05:52 PM


All times are GMT +5.5. The time now is 08:09 PM.