Solved

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

Posted on 2002-04-12
9
1,019 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
  • 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SSRS expression Issue finding a string 10 79
Determine Range to Select 5 48
Using "ScreenUpdating" 6 64
Run code from text file in vb 1 64
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

773 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