|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Accessing DB through VBHello,
Im trying to access DB through VB and i found on help topics that i need OLDB object/ DataBase Object and so. How do I add these components into my workspace? I don't think they exist in my project. Thank you! <Saba***@gmail.com> wrote in message
news:0f76d48a-fd33-4f89-9ded-30b1837c1811@c30g2000hsa.googlegroups.com... If you mean the ADODB objects, add a reference to "Microsoft ActiveX Data > Hello, > Im trying to access DB through VB and i found on help topics that i > need OLDB object/ DataBase Object and so. > How do I add these components into my workspace? I don't think they > exist in my project. > > Thank you! Objects". You can use the latest version listed. On 17 × ×•×‘×ž×‘×¨, 16:43, "Richard Mueller [MVP]" <rlmueller-
nos...@ameritech.nospam.net> wrote: Show quote > <Saba***@gmail.com> wrote in message Thanx> > news:0f76d48a-fd33-4f89-9ded-30b1837c1811@c30g2000hsa.googlegroups.com... > > > Hello, > > Im trying to access DB through VB and i found on help topics that i > > need OLDB object/ DataBase Object and so. > > How do I add these components into my workspace? I don't think they > > exist in my project. > > > Thank you! > > If you mean the ADODB objects, add a reference to "Microsoft ActiveX Data > Objects". You can use the latest version listed. > > -- > Richard Mueller > Microsoft MVP Scripting and ADSI > Hilltop Lab -http://www.rlmueller.net > -- "Dim dbMyDB As Database"
Where is the Database object? I added the activx data object, and it's not included... is there any place that maps object with it's reference? like in java? <Saba***@gmail.com> wrote in message
news:e0240ebd-685c-4c20-9eee-a8ab7a6eacbd@c30g2000hsa.googlegroups.com... [Just to make sure - you are using VB6 or lower and not VB.Net. Correct?]> "Dim dbMyDB As Database" > > Where is the Database object? > I added the activx data object, and it's not included... > is there any place that maps object with it's reference? like in java? The declaration "Dim dbMyDB As Database" is only half of the story. It only declares an 'Object Reference Variable'. To get an object you need to create one (instance) by using the New operator and assign it to the reference. Set dbMyDB = New Database. [Incidently while there are precedence rules which will allow implict dereferencing, you should get in the habit of always using explict references. ie.... "Dim dbMyDB As ADODB.Database "Set dbMyDB = New ADODB.Database" After the Set statement the object is now in memory (heap), and can be referenced through the reference variable. The 'mapping' is done for you behind the scenes. When you add a Reference (Project -> References) the type library for the component is read in into the project. These references are stored in the VBP file. Which you can see if you open the file with a text editor. You remove a Reference assignment by setting it to Nothing.... Set dbMyDB = Nothing. Note: this ony decreases the reference count to the object. When all references to the Object are removed then the Object is destroyed. References are also removed when the Reference varible goes out of scope. I suggest if at all possible you get a beginning VB book. While all language platforms have elements in common, there are always enough differences to get you in trouble should you continually try to compare one with the other. VB is not Java. <g> hth -ralph |
|||||||||||||||||||||||