MS Access - make connection - use class

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi -- I'm claiming once again that I'm new to this -- and I really am, it's just taking a long time to pick up what I need.

I'm reading through Dobson's book on VB.net and MS Access. I can connect to a database as follows:

Dim m_DB As New ADODB.Connection
Dim m_COB As New ADODB.Recordset

m_DB.Open("Provider=Microsoft.Jet.oledb.4.0;" & _
"Data Source=..\..\report1.mdb;", "Admin", "")

m_COB.ActiveConnection = m_DB
m_COB.Open("Delete * FROM T_Class", , _
ADODB.CursorTypeEnum.adOpenKeyset, _
ADODB.LockTypeEnum.adLockOptimistic)

I have a couple of questions.

First, I have no idea what the adOpenKeyset or adLockOptimistic means, I'm just copying them down. I'd appreciate any insight.

Second, I'd like to create a class with the skeletons of this stuff, for example...
m_DB.Open("Provider=Microsoft.Jet.oledb.4.0;" & _
"Data Source=..\..\report1.mdb;", "Admin", "")

I was thinking I could instantiate something like the m_DB by passing report1.mdb as a parameter. I can't figure out how to do this. I tried to create a class and inherit ADOB.connection -- this doesn't work. It tells me that I can only inherit from a class.

I realize that it's pretty obvious that I don't know what I'm doing, but I'm hoping that someone can clear up a few of these points for me.

Thanks,

Art
 
Hi Art,

Do you have a library near you.

There is only one advice I can give you, try to get another book.

This is using classic VB in VB.net, not the best practice.

You would have to look at Ado.net (this is called classic ADO, the letters
looks the same however it is totally different)

Another approach can be to use the resource kit.

http://msdn.microsoft.com/vbasic/vbrkit/default.aspx

And if you have problems installing it

http://msdn.microsoft.com/vbasic/vbrkit/faq/#installvdir

I hope this helps a little bit?

Cor
 
Art said:
First, I have no idea what the adOpenKeyset or adLockOptimistic
means, I'm just copying them down. I'd appreciate any insight.


Here's the ADO documentation:
http://msdn.microsoft.com/library/en-us/ado270/htm/dasdkadooverview.asp

CursorTypeEnum docs here:
http://msdn.microsoft.com/library/en-us/ado270/htm/mdcstcursortypeenum.asp

Both also available via <F1>.

Sorry, no answer to your 2nd question.

You could also consider using ADO.Net instead of unmanaged ADO.


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
Cor

Thanks very much. After reading your note I went back to the book (since its title says VB.Net). It looks like Dobson may have started with the classic VB for those who were comfortable with classic VB but never used Access (I'm guessing). Anyway, it appears that further on he titles some chapters with ADO.Net

Until I read your note it didn't occur to me that there was something else to look forward to. I'll read ahead, it's probably better than continuing to proceed linearly through the book

What is the "resource kit"

Thanks

Art
 
Armin

Thanks very much -- as you and Cor pointed out I'm not reading how to do this stuff using ADO.net -- something I wasn't aware of. Thanks for pointing it out and also for directing me to some documentation

Art
 
Hi Art,

It is a bunch of samples, lessons etc how to use VB.net, while there are
also free components in it.

It covers Windows, Adonet, Aspnet and compactframework.

I hope this clears it something?

Cor
 
Back
Top