Wrox Programmer Forums
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 28th, 2007, 11:15 PM
Registered User
 
Join Date: Oct 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to CoolEJ
Default Creating Active X DLL

Hi, I currently have a database with multiple tables.
I need to create an Active X (VB6) to update fields with data from fields on another table.

Example:
Field 1 from Table 1 is updated with data from Field3 Table 2.


Please help me to create this one.

Thanks,
Eric

EJC
 
Old November 29th, 2007, 08:32 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

well.. you can execute a query to do this:

UPDATE table1 SET field1 = (SELECT field3 FROM table2 WHERE (something that return only 1 row of data))

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old November 29th, 2007, 08:44 AM
Registered User
 
Join Date: Oct 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to CoolEJ
Default

Hi,

Thanks for the reply. That's SQL statement and I can handle that.

My problem is more on how to use VB6 ActiveX DLL to connect to the database and execute that SQL statement.

Please help me out.

Thanks



EJC
 
Old November 29th, 2007, 08:58 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

A activeX DLL could be an exe that run alone.. or you have to call it from another program???





HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old November 29th, 2007, 02:54 PM
Friend of Wrox
 
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It would be helpful if you could be specific about what problems you are having.

Are you familiar with making ActiveX dlls in VB6? As you are probably aware, VB6 makes this very simple. Let us know if this is where you need guidance, and what exactly you are having trouble with.

The basics of creating a dll are as follows:
- Start up a new project, and select the ActiveX dll icon to create a project.
- Put your code into the class provided - but give the class a name that has meaning to your project.
- Yoo have to have public properties and methods (functions or subs) for the class to be useful (or to even compile if I remember correctly).

To test this new dll, you can add a standard exe project to the project group (using the main menu > add project dialog) and set it as the start-up project. You will then need to add a reference to the dll in project > references, and write some code to use the dll.

Once everything is done, you will need to provide an installer that your users will use to install the dll on their computer.

That is pretty much the basics - I left out all the details.

If this is your first project devloping COM dlls, you are in for a lot of fun. And I am using the word fun to mean "headaches". Of course, for most of us the issues with COM dlls are slowly fading into history since a new mechanism for RPC is used in the .NET world. We still have dlls, but now the are "managed" and do not use the registry for locating them (as well as a lot of other changes).

Woody Z
http://www.learntoprogramnow.com
How to use a forum to help solve problems
By blog... please visit
 
Old November 29th, 2007, 10:24 PM
Registered User
 
Join Date: Oct 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to CoolEJ
Default

Hi,
I'm calling this from another program. This program only works with VB6.0 DLLs.

I'm using a SQL database and it's my first time dealing with VB 6.0.
My SQL database has two tables. Let's name it table 1 and table 2. When a record is created in Table 2, I want a DLL to update a field(Let's say field1) in Table 1 with the data(Let's say field999) from the new record added in Table 2.

I can execute it in stored procedure but the program is presently limited to VB6.0 ActiveX DLL.

To do this (I think):
1. the DLL must connect to the database
2. Execute the SQL Statement (Update etc...)

I need help for no.1 and I haven't seen an actual ActiveX with SQL statements in it before. Maybe an example too?

I'd highly appreciate this.

EJC
 
Old November 29th, 2007, 10:27 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

well.. conecting a dll is the same as conecting any exe file.. you should google about how to connect to a database in vb6...

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old November 30th, 2007, 02:29 PM
Friend of Wrox
 
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here is a very minimal example.
Get this to work, and then let us know what you are having trouble with.

Note that this example uses a database named wroxtest.mdb, which has a table named Vocabulary with 3 columns:
1 - Id (autonumber0
2 - Name (a text field)
3 - Description (a text field)

Your dll project must have a reference to the ADODB dll.

Code:
Public Function DoDataWork(ByVal name As String, ByVal description As String) As Integer
    ' Your connection object
    Dim cn As ADODB.Connection    
    ' You can get back the number of records affected, so we will put it into a variable named result.
    Dim result As Integer

    ' Instantiate the connection
    Set cn = New ADODB.Connection
    ' Assign the connection string
    cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\wroxtest.mdb;"
    ' And, guess what?  Open the connectino
    cn.Open
 
    ' A simple insert statement
    cn.Execute "Insert Into vocabulary (Name, Description) Values ('" & name & "', '" & description & "')", result

    ' Always close your connection - this is imoprtant
    cn.Close

    ' Result will always contain one in our little example
    DoDataWork = result
End Function
Of course, you now need some code to instantiate and use your new dll.


Woody Z
http://www.learntoprogramnow.com
How to use a forum to help solve problems
By blog... please visit





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to fire events of a Active X dll in ASP.NET Brijendra Pandey ASP.NET 3.5 Professionals 1 October 4th, 2008 05:44 PM
DTSHelper Active X dll ErinG SQL Server DTS 0 March 15th, 2007 09:10 AM
Creating Active X Components mahulda ASP.NET 1.0 and 1.1 Basics 2 January 14th, 2006 10:00 AM
Active Directory - Creating Groups r_ganesh76 ASP.NET 1.0 and 1.1 Professional 1 October 4th, 2004 06:43 AM
Pass active X control from c++ to VB DLL rraags Visual C++ 2 June 8th, 2004 02:28 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.