Avatar billede sdn Nybegynder
14. april 2005 - 13:40 Der er 6 kommentarer og
2 løsninger

Eksport af tabel

Hej

Jeg har en database "DB1.mdb" som består af en backend og et frontend modul som flere brugere benytter i et mindre lokalt netværk.

Desuden har jeg en webside som køre op imod DB2.mdb hvor der kun læse data fra.

Nu vil jeg gerne lave en eksport af en tabel (table1) fra min DB1.mdb og som skal udgøre min DB2.mdb.

Hvordan får man den eksport klaret via en macro eller på anden automatisk vis imens der stadig er brugere som benytter DB1 via deres frontend modul ?
Avatar billede jensen363 Forsker
14. april 2005 - 13:52 #1
Ligger DB2 på en ekstern server ?
Avatar billede sdn Nybegynder
14. april 2005 - 14:00 #2
ja, men den vil jeg uploade via WS FTP pro, som jo kan sættes til at auto uploade.

Således at operationen er to delt. Først eksport af data f.eks. hver time og efterfølgede upload via WS FTP pro.
Avatar billede sdn Nybegynder
14. april 2005 - 14:09 #3
Selve eksporten foregår lokalt på WIN2K Server.
Avatar billede terry Ekspert
14. april 2005 - 15:09 #4
not quite sure I understand the problem? Do you want to run the SQL at fixed times? If so then you should make the export macro in Access and then using the Windows Scheduler start Access running the macro

THese are the start up command line parameters you can with Access

Startup command-line options 
Show All
Hide All
The following table lists the Microsoft Access command-line options.

Option Effect
database  Opens the specified Microsoft Access database (database: A collection of data related to a particular subject or purpose. Within a database, information about a particular entity, such as an employee or order, is categorized into tables, records, and fields.) or Microsoft Access project (Microsoft Access project: An Access file that connects to a Microsoft SQL Server database and is used to create client/server applications. A project file doesn't contain any data or data-definition-based objects such as tables and views.). Include a path if necessary. 
/excl Opens the specified Access database for exclusive (exclusive: A type of access to data in a database that is shared over a network. When you open a database in exclusive mode, you prevent others from opening the database.) access. To open the database for shared access in a multiuser (multiuser (shared) database: A database that permits more than one user to access and modify the same set of data at the same time.) environment, omit this option. Applies to Access databases only.
/ro Opens the specified Access database or Access project for read-only access.
/user user name Starts Access by using the specified user name. Applies to Access databases only.
/pwd password Starts Access by using the specified password. Applies to Access databases only.
/profile user profile Starts Access by using the options in the specified user profile instead of the standard Windows Registry settings created when you installed Microsoft Access. This replaces the /ini option used in versions of Microsoft Access prior to Access 97 to specify an initialization file.
/compact target database or target Access project Compacts and repairs the Access database, or compacts the Access project that was specified before the /compact option, and then closes Access. If you omit a target file name following the /compact option, the file is compacted to the original name and folder. To compact to a different name, specify a target file. If you don't include a path in target database or target Access project, the target file is created in your My Documents folder by default.
In an Access project, this option compacts the Access project (.adp) file but not the Microsoft SQL Server database.

/repair Repairs the Access database that was specified before the /repair option, and then closes Microsoft Access. In Microsoft Access 2000 or later, compact and repair functionality is combined under /compact. The /repair option is supported for backward compatibility.
/convert target database Converts a previous-version Access database or Access project to Access 2000 file format, renames the new file, and then closes Access. You must specify the source database before you use the /convert option. 
/x macro Starts Access and runs the specified macro. Another way to run a macro when you open a database is to use an AutoExec macro.
Caution  Macros can contain viruses, so you must be careful about running them. Take the following precautions: run up-to-date antivirus software on your computer; set your macro security level to high; use digital signatures; maintain a list of trusted sources of macros.

/cmd Specifies that what follows on the command line is the value that will be returned by the Command function. This option must be the last option on the command line. You can use a semicolon (;) as an alternative to /cmd.
Use this option to specify a command-line argument that can be used in Visual Basic (Microsoft Visual Basic: A high-level, visual-programming version of Basic. Visual Basic was developed by Microsoft for building Windows-based applications.) code.

/nostartup Starts Access without displaying the task pane (task pane: A window within an Office application that provides commonly used commands. Its location and small size allow you to use these commands while still working on your files.) (the second dialog box that you see when you start Access).
/wrkgrp workgroup
information file Starts Access by using the specified workgroup information file. Applies to Access databases only
Avatar billede sdn Nybegynder
14. april 2005 - 15:31 #5
Terry > jeg forklare den helt simple:

Hvordan kan jeg lave en automatisk eksport af en tabel (table1) i databasen db1.mdb mens  db1.mdb er åben ?

Den eksporterde table1 skal oveskrive en tilsvarende table1 i databasen db2.mdb som er ej er åben.

Giver det mening ?
Avatar billede terry Ekspert
14. april 2005 - 15:45 #6
I'm sure there are a number of different which this can be done, but I dont think there is any EASY way to do this.

If db1 and db2 on the same network then I would link the tables from db2 into db1 Then I would make code in db1 which can copy the data from db1.table1 to db2.table1 (linked).

I dont have enough information on exactly what you need to export/import so I can say exactly what your code should do.
It may for example delete th erecords in db2 and then INSERT the records from db1!

Then IF you need to run the code onece a day for example, then you WILL need to use something like Windows scheduler to run a macro in the db1 which runs the code. It should be possibe to do this even if the dB is opened!
Avatar billede sdn Nybegynder
16. august 2005 - 17:43 #7
jeg fandt en meget nem løsning...lang om længe!
Lavede et simpelt script i en bat fil som kopierer database filen over i en upload mappen. Data i denne mappe blev så kopieret over på min webserver via ftp. OG det virker!

Eneste minus er at jeg har ALLE data i min databse med ud på webserveren. Men da databasen er ret lille og ikke indeholder kritiske oplysninger er det OK.
Avatar billede terry Ekspert
16. august 2005 - 19:55 #8
Hi sdn and thanks for the points.

To copy just one table to another dB you can use the following code (example) but you will need to call a macro in Access to do this.

DoCmd.TransferDatabase acExport, "Microsoft Access", "C:\test.mdb", acTable, "tblOrdre", "tblOrdre"

The database ("C:\test.mdb") must already exist.

mvh
Terry
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester