?
Solved

How do I convert a Foxpro 2.6 database into MySQL ?

Posted on 2003-11-04
8
Medium Priority
?
489 Views
Last Modified: 2006-11-17
How do I convert a Foxpro 2.6 database into MySQL ?
asim
0
Comment
Question by:masimiqbal
[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
  • 3
  • 2
8 Comments
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9676976
download the mysql odbc diver and create an dsn

create a link table in access for the the foxpro database then right click select export choose the odbc database and select your dsn Thats it you are done!
0
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9677504
can you please close 2 other questions? write to the community support to close them.
if you want to convert foxpro programtically generate the sql statements and fire them
0
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9684205
masimiqbal:you can download mysql odbc driver from mysql's site
0
 
LVL 3

Accepted Solution

by:
steve918 earned 500 total points
ID: 9731469
* Heres a program I wrote to do just that.
* 1. Copy this text to foxtosql.prg
* 2. In foxpro run: Do foxtosql "database.dbf", "outfile.sql"
* 3. Now Run: mysql -uuser -ppass database<outfile.sql
*
* Note:  You must first create the database in mysql this program does not
* produce the table structure.  You could easily tweak it to produce the table
* structure, but I prefer to build the table the way I want it in mysql instead
* having the program guess at data types and such.
 
PARAMETERS pDBF,pOutfile

Private xi
Private xCOLARRY


Set TEXTMERGE ON
SET TEXTMERGE TO &pOutFile

If !USED(pDbf)
      SELECT 0
      Use &pDBF
EndIf

=Afields(xCOLARRY)

Scan

      \INSERT INTO todo VALUES ('

      For xi = 1 to int(alen(xCOLARRY)/4)
            
            Do Case
                  Case Inlist(xCOLARRY(xi,2),"C","M")      
                        xStr = &xCOLARRY(xi,1)
                        \\<<Alltrim(_SpecChars(xStr))>>
                        xStr = ""
                  Case Inlist(xCOLARRY(xi,2),"F","N")
                        xNum = &xCOLARRY(xi,1)
                        \\<<Alltrim(Str(xNum))>>
                        xNum = 0
                  Case xCOLARRY(xi,2) = "D"
                        xDate = &xColArry(xi,1)
                        \\<<Alltrim(_FmtDate(xDate))>>
                        xDate = {}
            EndCase
      
            If !(xi=int(alen(xCOLARRY)/4))      
                  \\','
            EndIf

      EndFor

      \\');

EndScan

flush
close all

*
*
*
Function _FmtDate
Parameters pDate

Private xDate
Private xMon
Private xYear
Private xDay

If Empty(pDate)
      Return( "0000-00-00" )
EndIf

pDate = dtos(pDate)
xYear = Left(pDate,4)
xMon = Substr(pDate,5,2)
xDay = Right(pDate,2)

xDate = xYear + "-" + xMon + "-" + xDay
Return( xDate )


*
*
*
Function _SpecChars
      Parameters xTodo

      xTodo = Strtran(xTodo,"\","\\")
      xTodo = Strtran(xTodo,chr(13),"\r")
      xTodo = Strtran(xTodo,chr(10),"\n")
      xTodo = Strtran(xTodo,chr(09),"    ")
      xTodo = Strtran(xTodo,'"','\"')
      xTodo = Strtran(xTodo,"'","\'")


      Return(xTodo)
0
 
LVL 3

Expert Comment

by:steve918
ID: 9731484
LOL, I just realize the _SpecChars function uses xTodo as a parameter, I built this program to convert a "TODO" database from foxpro to MySQL
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Six Sigma Control Plans
Suggested Courses

752 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