Solved

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

Posted on 2002-04-12
9
1,001 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 69

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 69

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
 

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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 69

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 69

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 69

Expert Comment

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

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now