Vb 6 not recognise Access 2010 (accdb)

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

31 Replies - 6251 Views - Last Post: 11 June 2013 - 03:16 AM Rate Topic: -----

#16 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: Vb 6 not recognise Access 2010 (accdb)

Posted 18 May 2013 - 10:22 AM

View PostJephor, on 18 May 2013 - 11:00 AM, said:

Dim Conn As ADODB.


ADODB is the "Component". A component is a bunch of related classes grouped into a single DLL (dynamic link library) file. When you set a reference to the ADODB component, you have access to all of its classes. The Connection class is one of these. So, your syntax is Dim Conn as ADODB.Connection, or simply Dim Conn as Connection if you don't have any other DLLs that you are using that have a Connection class. The reason we usually specify ADODB is because a lot of the classes have the same names as DAO--an older technology based on ODBC--classes. So, if you can't get a Connection to work, start there.

Once you've taken a crack at getting something to work, post your code and we'll help you fix it if you need us to.

This post has been edited by BobRodes: 18 May 2013 - 10:25 AM

Was This Post Helpful? 2
  • +
  • -

#17 Jephor  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 06-May 13

Re: Vb 6 not recognise Access 2010 (accdb)

Posted 19 May 2013 - 08:18 AM

Dear Bob

Thank you for taking the time to explain and to point me in the right direction, feeling more positive that i can do this :-)

I have attached a pdf that shows two variationson on a connection theme! would very much appreciate your guidance... It compiles fine, but when i run the program the database contents do not show on the data grid object. I tried to set the RecordSource to cmdTable - but it came up with the error message shown... it did this for both variations.

What am i missing out?

Best regards

Attached File(s)

  • Attached File  ADOCB.pdf (739.84K)
    Number of downloads: 33

Was This Post Helpful? 0
  • +
  • -

#18 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: Vb 6 not recognise Access 2010 (accdb)

Posted 19 May 2013 - 11:32 AM

View PostJephor, on 19 May 2013 - 10:18 AM, said:

Dear Bob

Thank you for taking the time to explain and to point me in the right direction, feeling more positive that i can do this :-)

I have attached a pdf that shows two variationson on a connection theme! would very much appreciate your guidance... It compiles fine, but when i run the program the database contents do not show on the data grid object. I tried to set the RecordSource to cmdTable - but it came up with the error message shown... it did this for both variations.

What am i missing out?

Best regards


The ADODB objects replace the data control. Get rid of it entirely. Next, your data source name isn't found almost certainly because you have C:\program file instead of C:\program files. You're missing an "s".

Use breakpoints and the immediate window to work through this. Learn how if you don't know how.
Was This Post Helpful? 2
  • +
  • -

#19 Jephor  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 06-May 13

Re: Vb 6 not recognise Access 2010 (accdb)

Posted 19 May 2013 - 01:10 PM

Hi Bob
No joy :-(
Are you able to provide me with an example connection string so that i can see what a working one looks like.... once i see how a connection string is structured i am sure that i can then figure things out - its working blind that is so fruastring!

Thank you so much for not giving up on me :-)

ps did not understand what you meant by get rid of data control - not aware i had one, only datagrid and ADOCB objects... as i said very very rusty............
Was This Post Helpful? 0
  • +
  • -

#20 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 299
  • View blog
  • Posts: 1,768
  • Joined: 26-March 09

Re: Vb 6 not recognise Access 2010 (accdb)

Posted 20 May 2013 - 12:20 AM

You can check out this link for details on connection strings.
Was This Post Helpful? 0
  • +
  • -

#21 Jephor  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 06-May 13

Re: Vb 6 not recognise Access 2010 (accdb)

Posted 20 May 2013 - 08:56 AM

With the utmost of respect - the more web pages i look at for solutions with regard to how a connection string should be constructed, the more confused i get, as there would appear to be any number of ways, i am just not able to get any of them to work. Is it not possible for someone to explicitly show - by coded example - what a 'complete' connection string should consist of (using dummy data) and also the order in which it should appear. I can then apply this to my own requirements and build accordingly... and hopefully achieve a successful outcome.

This is what my code looks like at the moment - a mishmash of web page suggested offerings

Private Sub Adodc1_WillMove(ByVal adReason As ADODB.EventReasonEnum, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)

Dim Conn As ADODB.Connection
Dim dbaseName As String
Dim Rs As Recordset

Provider = "Microsoft.ACE.OLEDB.12.0;dbaseName=C:\Users\Jepher\CMP_KS32010.accdb;Persist Security Info=False"
'the above line comes up with an error message if i remove the " " compiler does not like the OLEDB.12.0; part

Set Conn = New ADODB.Connection
Form1.Adodc1.ConnectionString = dbaseName
Conn.Open dbaseName

Set Rs = New ADODB.Recordset

End Sub


thank you to anyone who will kindly take a look and point me in the right direction (simple steps please)

This post has been edited by modi123_1: 20 May 2013 - 09:01 AM
Reason for edit:: highlight the text and just click the 'code' button in the text editor

Was This Post Helpful? 0
  • +
  • -

#22 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8947
  • View blog
  • Posts: 33,544
  • Joined: 12-June 08

Re: Vb 6 not recognise Access 2010 (accdb)

Posted 20 May 2013 - 09:10 AM

07	Provider = "Microsoft.ACE.OLEDB.12.0;dbaseName=C:\Users\Jepher\CMP_KS32010.accdb;Persist Security Info=False"
08	'the above line comes up with an error message if i remove the " " compiler does not like the OLEDB.12.0; part



Change "dbaseName" => "Data Source".
Slap a semicolon after 'false'.
Was This Post Helpful? 0
  • +
  • -

#23 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3227
  • View blog
  • Posts: 10,837
  • Joined: 12-December 12

Re: Vb 6 not recognise Access 2010 (accdb)

Posted 20 May 2013 - 09:15 AM

It should be Conn.Provider = ".." as well, but there are other errors. Study this page:

http://msdn.microsof...y/ms807027.aspx
Was This Post Helpful? 1
  • +
  • -

#24 Jephor  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 06-May 13

Re: Vb 6 not recognise Access 2010 (accdb)

Posted 20 May 2013 - 09:45 AM

View Postmodi123_1, on 20 May 2013 - 09:10 AM, said:

07	Provider = "Microsoft.ACE.OLEDB.12.0;dbaseName=C:\Users\Jepher\CMP_KS32010.accdb;Persist Security Info=False"
08	'the above line comes up with an error message if i remove the " " compiler does not like the OLEDB.12.0; part



Change "dbaseName" => "Data Source".
Slap a semicolon after 'false'.


Thanks MODi 123 1 - no joy but thank you for trying

Andrew - your link looks promising :-) thank you :-)
Was This Post Helpful? 0
  • +
  • -

#25 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: Vb 6 not recognise Access 2010 (accdb)

Posted 21 May 2013 - 09:03 PM

ADODC is the ADO Data Control. If you don't have such a control on your form, code that references it will throw an error. Also, the WillMove event is an event of this data control, so you'll never call that code if there isn't one. In any case, if you do have one, get rid of it.

The connectionstring has several components, all as one string value. The components are separated by semicolons. The first component is the Provider. This is an OLE DB Provider, which is an implementation of a series of classes that are used to access data. This way, OLE DB consumers (such as ADO) can work with a common interface to access any sort of data source.

The second component is the Data Source. With Access, this will simply be a reference to an Access file.

Then, Persist Security Info, which is generally false, says whether the local accessor of the data can save a password for later use.

So, the syntax is
Dim cn as ADODB.Connection
Set cn = New ADODB.Connection
cn.ConnectionString = "Provider=someProvider;Data Source=someFile;Persist Security Info=False"
cn.Open


The reason that you're not getting any joy is because you are thinking that there's a variable called "Provider" that is set equal to the rest of the connectionstring. If you look at the above example and the examples in the link that maj provided, you will see that that isn't how to do it. :) Hint: Access 2007 and Access 2010 use the same connection string.

Once you've fixed that, post your code changes and we'll see what's up.
Was This Post Helpful? 2
  • +
  • -

#26 Jephor  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 06-May 13

Re: Vb 6 not recognise Access 2010 (accdb)

Posted 22 May 2013 - 01:57 PM

View PostBobRodes, on 21 May 2013 - 09:03 PM, said:

ADODC is the ADO Data Control. If you don't have such a control on your form, code that references it will throw an error. Also, the WillMove event is an event of this data control, so you'll never call that code if there isn't one. In any case, if you do have one, get rid of it.

The connectionstring has several components, all as one string value. The components are separated by semicolons. The first component is the Provider. This is an OLE DB Provider, which is an implementation of a series of classes that are used to access data. This way, OLE DB consumers (such as ADO) can work with a common interface to access any sort of data source.

The second component is the Data Source. With Access, this will simply be a reference to an Access file.

Then, Persist Security Info, which is generally false, says whether the local accessor of the data can save a password for later use.

So, the syntax is
Dim cn as ADODB.Connection
Set cn = New ADODB.Connection
cn.ConnectionString = "Provider=someProvider;Data Source=someFile;Persist Security Info=False"
cn.Open


The reason that you're not getting any joy is because you are thinking that there's a variable called "Provider" that is set equal to the rest of the connectionstring. If you look at the above example and the examples in the link that maj provided, you will see that that isn't how to do it. :)/> Hint: Access 2007 and Access 2010 use the same connection string.

Once you've fixed that, post your code changes and we'll see what's up.


Hi Bob

Thank you very much for your help, I feel (at long last) that understanding is coming my way :-) I guess i am now upto the RecordSource part? Have had a go as you can see, but still no joy :-(

Would again appreciate your guidance

Best regards

Hi Bob

Thank you very much for your help, I feel (at long last) that understanding is coming my way :-) I guess i am now upto the RecordSource part? Have had a go as you can see, but still no joy :-(

Would again appreciate your guidance

Best regards

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

#27 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: Vb 6 not recognise Access 2010 (accdb)

Posted 26 May 2013 - 09:50 PM

As I have said a few times already, get rid of the ADODC. The data control. Delete it from your form. Then learn about the Recordset object. You can't use your connection object with your data control. Your connection object looks fine, but the control can't see it. Also, you have it in the control's willmove event. This only gets fired when you are about to move from one record to another using the data control, and if you declare your object in there, that's the only time that your application can see it. So, you're all mixed up, and won't let go of the mess.

When you are willing to follow through on the suggestions given, do so and post back. :hammer:
Was This Post Helpful? 0
  • +
  • -

#28 Jephor  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 06-May 13

Re: Vb 6 not recognise Access 2010 (accdb)

Posted 28 May 2013 - 01:41 PM

Hi Bob, thank you for the clarification :-) I post my next attempt at trying to create a working connection and again look forward to your feedback. Regards

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

#29 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8947
  • View blog
  • Posts: 33,544
  • Joined: 12-June 08

Re: Vb 6 not recognise Access 2010 (accdb)

Posted 28 May 2013 - 01:45 PM

Please post the code in the forum and not wrapped in some screen shot shoved inside a PDF. It would make it easier for everyone.. also writing out the exception (or at least inserting an 'IMAGE' to the exception) would be helpful as well.
Was This Post Helpful? 0
  • +
  • -

#30 Jephor  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 06-May 13

Re: Vb 6 not recognise Access 2010 (accdb)

Posted 30 May 2013 - 05:05 AM

To all of you that sought to assist me i say thank you but now intend to close my question thread down. I feel that this forum is not the right avenue for me. Instead i would like to ask if any of you know the title of a good book that will offer both the option to code as well as make use of objects when wanting to connect a database application. I hope that someone will offer me this life line as i do so very much want to understand and learn how to code a connectivity solution using VB6 and Access 2010.

Best Regards.
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3