Solved

Can I create a .dbf file for db2 (AS400) ?

Posted on 2002-04-12
9
1,059 Views
Last Modified: 2008-03-06
I don't know a single thing about db2/as400.  I have someone that wants me to create a .dbf file that can be imported into their database.  Can this be done?  For me to accept the answer, I need an explanation of a .dbf file and how db2 uses it.  I also need to know if its just a matter of writing to a file with extension .dbf from VB.  Thanks.
0
Comment
Question by:jackjeckyl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6937085
dbf files are the dBase format (remember that products). It is a proprietary format.

Prefer using another format (a csv file for example - whihc is nothing more than an ASCII file with fields separated with commas).

You can also connect to the AS/400 computer and fill the database from VB. See:
http://www.able-consulting.com/ADO_Conn.htm#ODBCDriverForAS400 
http://www.able-consulting.com/ADO_Conn.htm#OLEDBProviderForAS400FromIBM
0
 

Author Comment

by:jackjeckyl
ID: 6937147
I won't be connecting to the database, all I'm going to do is create a file for him.  Thus, he is going to give me specs and I will create a file from that.  So I can just write a file with a .dbf extension same as I would with a .txt?
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6937166
NO! dbf is a propietary format (the format used by dBase).

Suggest another format like a .csv file.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:jackjeckyl
ID: 6937192
OK, so VB CANNOT create a .dbf file?  or shouldn't?  I don't think the guy knows exactly what he wants.  I suggested a delimited type file, but he didn't seem too sure.  He insisted on a .dbf file, and I told him I would look into it.  No go?
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 50 total points
ID: 6937198
Have a look at
http://www.winsite.com/bin/Info?500000003589


I have also found this:



  ' Export Table from MDB-File into
  ' DBF-File-Format
  ' for dBase/Clipper
 
  Dim mdb_Table As String
  Dim dbf_Table As String
  Dim sql_statement As String
  Dim path_target As String
  Dim dbf_target As String
 
  ' declare Database-Object
  Dim MyDB As Database
 
  ' Source MDB-File
  mdb_Table = "C:\allpst\allpstneu.mdb"
 
  ' Table in MDB-File
  dbf_Table = "plan"

  ' Target-directory
  path_target = "C:\test"
 
  ' Target-DBF-File
  dbf_target = "newdbf"
 
  ' SQL-Statement
  sql_statement = "SELECT * INTO [dBase IV;database=" & path_target & "]." & dbf_target & " FROM " & dbf_Table
  'sql_statement = "SELECT * INTO [dBase IV;database=C:\test].newdbf FROM person"
     
  ' open the MDB-Database
  Set MyDB = DBEngine.OpenDatabase(mdb_Table)
 
  ' delete DBF-File before "copying"
  If UCase(Dir(path_target & "\" & dbf_target & ".dbf")) = UCase(dbf_target & ".dbf") Then
    Kill path_target & "\" & dbf_target & ".dbf"
  End If
 
  ' SQL-Statement and transfering data
  MyDB.Execute sql_statement
 
  ' close MDB
  MyDB.Close
 
  Set MyDB = Nothing
0
 

Author Comment

by:jackjeckyl
ID: 6937351
So if I wanted to write data to db2, I'd have to do it as a big insert statement.  I haven't seen anything that says to write to a .dbf file, do this.  Just the Access export to a .dbf.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6937366

This statement:
'sql_statement = "SELECT * INTO [dBase IV;database=C:\test].newdbf FROM person"

takes data from a "person" table stock anywhere and create a DBF file name "newdbf" into the "c:\test" folder. Isn't it what you are looking for?
0
 

Author Comment

by:jackjeckyl
ID: 6937399
I think I'm good.  Thanks for the help.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6937426
will you be back soon to close the question?
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question