473,395 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to run a procedure in a database from code in another DB?

dsatino
393 256MB
Basically, there is a pre-existing procedure in a DB. I want to to be able to run this procedure from a different DB.

Can this be done?
If so, how?
Oct 27 '10 #1

✓ answered by ADezii

Yes it can be done. Let's assume that you have an External Database named Test.mdb in the C:\Test Folder, namely: C:\Test\Test.mdb. To Execute a Public Sub-Routine named CountTablesInDB() in the External Database (Test.mdb), execute the following Code from the Current Database:
Expand|Select|Wrap|Line Numbers
  1. Dim appAccess As Access.Application
  2.  
  3. 'Create instance of Access Application object.
  4. Set appAccess = CreateObject("Access.Application")
  5.  
  6. 'Open Test Database in Microsoft Access window.
  7. appAccess.OpenCurrentDatabase "C:\Test\Test.mdb", False
  8.  
  9. 'Run Sub procedure.
  10. appAccess.Run "CountTablesInDB"
  11.  
  12. Set appAccess = Nothing

2 22089
ADezii
8,834 Expert 8TB
Yes it can be done. Let's assume that you have an External Database named Test.mdb in the C:\Test Folder, namely: C:\Test\Test.mdb. To Execute a Public Sub-Routine named CountTablesInDB() in the External Database (Test.mdb), execute the following Code from the Current Database:
Expand|Select|Wrap|Line Numbers
  1. Dim appAccess As Access.Application
  2.  
  3. 'Create instance of Access Application object.
  4. Set appAccess = CreateObject("Access.Application")
  5.  
  6. 'Open Test Database in Microsoft Access window.
  7. appAccess.OpenCurrentDatabase "C:\Test\Test.mdb", False
  8.  
  9. 'Run Sub procedure.
  10. appAccess.Run "CountTablesInDB"
  11.  
  12. Set appAccess = Nothing
Oct 28 '10 #2
dsatino
393 256MB
Perfect. Thanks a million.
Nov 1 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Tom Frank | last post by:
Hi, Anybody have an idea of copying data from tables of a database to another database. It should be a choice to select all tables, single table or several tables. For them knowing Oracle it...
0
by: Bob | last post by:
How can I copy query objects from one MS Access database to another using VB.net. Both databases are on the same computer. As I create a report using vb.net, I create and reference queries in a...
2
by: Nate | last post by:
Hello, I am trying to recover a SQL Server 7 database from another hard disk drive that has a corrupted Windows 2000 Advanced Server installation. I am not able to repair the corrupted Windows...
1
by: kjphipps_377 | last post by:
Hi all! I have an application that needs to copy the database structure from one database to another without using the "Generate SQL Script" function in Enterprise Manager. I'd like to do this...
1
by: Jani Tamminen | last post by:
I want to copy data from our production database to the development database. I want to move only the data. I do not need the table structure, constrains or anything else. I think I can use the...
2
by: Woody Splawn | last post by:
I am using SQL Server 2000 as the back-end. I have created a stored procedure in SQL server called usp_AddContract. This Stored procedure inserts a new contract into a contracts table. I have...
1
by: shalini0702 | last post by:
Hi, I have Missing Records when exporing a table from (msaccess) One database to another. Supppose My Db has 10 tables and expoting all the table from One database to another was correct. ...
2
by: nosipho | last post by:
Hello guys, I need to copy a database in SQL 2000 to another SQL2000 server. I tried backing up the database to a folder then restore it but it's not happening. Please help to know how to copy...
2
by: wertqt | last post by:
Hi all, Im using C#.Net to write a program on updating system (autoamtion project). However, im new to this language and does not have much knowledge on it. I have some doubts on the source...
0
by: rajaaryan44 | last post by:
how can we transfer data from one access database to another databse . the table name is same for both the database . in one table some records are there (rs say e.g.) now another table has say...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.