VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)
首页 - 经验之谈 - 数据库的一些出口类型
发表评论(0)作者:不详, 平台:VB6.0+Win98, 阅读:11243, 日期:2001-04-12
Export to any type of database

Everyone tells you how to import, but even most MS-VB techs start coughing when you ask how to export with DAO!

Use this code to get data out to different formats without requiring a complete copy of any DBMS on the user machine.

Create a new project with a command button and a DAO3.5 reference, then copy this code to the button注释:s Click event (snippet assumes the MS sample file biblio.mdb is in the application path):

Dim db as database
Set db = Workspaces(0).OpenDatabase(app.path & "iblio.mdb")
注释:commented out syntax followed by working example
注释:db.execute "SELECT tbl.fields INTO [dbms type;DATABASE=path].[unqualified 注释:filename] FROM [table or tables]
db.execute "SELECT * INTO [dBase III;DATABASE="C:My Documents].[testa] FROM [authors]"By using the brackets and dot operator, you get a completely proper output in the ISAM database type of your choice. Also, if you choose Text as the database type, the statement creates a Schema.ini for you automatically, or adds a new section for your new data file to a Schema.ini already in the path folder.

Now you can do any kind of export the client wants without using a DBMS on the machine. This makes your life easier when you notice that some of your users running Word97 have problems mail-merging with text files you originally created with traditional (and slower) Write# and Print# methods.