Best Practice - Convert from VFP


Author
Message
Michel Levy
Michel Levy
StrataFrame User (441 reputation)StrataFrame User (441 reputation)StrataFrame User (441 reputation)StrataFrame User (441 reputation)StrataFrame User (441 reputation)StrataFrame User (441 reputation)StrataFrame User (441 reputation)StrataFrame User (441 reputation)StrataFrame User (441 reputation)
Group: StrataFrame Users
Posts: 193, Visits: 9K
Thank you for that explanation, Charles.

New upsizing wizard allows us to create clustered indexes on PK, and migrate VFP RI triggers in SQL constraints. Of course, it's not a magic tool, and I never trust it, and always set the final conversion in SSMS and DDT.

Since VFP6, I use RI with no failure or problem. Moving apps in VFP8, I used autoinc PK.

We have different experiences with Fox and SQL, so we can learn each from others.

Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
All my VFP stuff used GUID pks and I was originally drawn to Full Convert because unlike the "upsizer" it would let me map my GUIDs to UIDs. I never used autoinc integers in VFP databases.



Most of my VFP -> conversion was done for other peoples apps as I started developing VFP apps exclusively against SQL starting about 2002.



I usually found that RI ( especially straight VFP RI without Steve Sawyer's brilliant mod ) wasn't something I wanted to even think about converting so I just moved the table data and set up the RI triggers where appropriate in SQL itself after the data was moved.



When on the Table Setting screen I would only check Recreate Data ( having already created the structure I wanted with DDT ) and then check Skip Indexes and Skip Constraints.



I found it was better to move the data from VFP to SQL without indexes or RI or defaults - ie. data only - no metadata - and then set things up in sql the way I wanted it. I don't trust any "automatic" conversion of that kind of stuff as I always assumed ( perhaps incorrectly ) that the VFP implementation of some of that stuff may have been done to look like SQL it really was different ( RI being a good example )



Full Convert's primary utility for me was in mapping the fields and doing the actual data transfer and storing those setting in projects so they were reproducable and tweakable. I found the VFPOLEDB driver flakey or I would have done it from the SQL side with DDT / SSIS.





Michel Levy
Michel Levy
StrataFrame User (441 reputation)StrataFrame User (441 reputation)StrataFrame User (441 reputation)StrataFrame User (441 reputation)StrataFrame User (441 reputation)StrataFrame User (441 reputation)StrataFrame User (441 reputation)StrataFrame User (441 reputation)StrataFrame User (441 reputation)
Group: StrataFrame Users
Posts: 193, Visits: 9K
Charles

playing with the trial version of FullConvert, I'm unable to automatically convert VFP autoinc fields as SQL int identity, nor to convert PK.

Is it a limitation in the trial version? do you really convert all  referential integrity with this tool?

Howard Bennett
Howard Bennett
StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)
Group: Forum Members
Posts: 57, Visits: 496
Now - that's a good idea (restructuring tables in VFP - then using Full Convert to move.) Hadn't thought of that.



Thanks again!!!



HB
Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
Even with significant structure changes at some point you have to move the VFP data into SQL tables. My approach, since I was most familiar with manipulating data in VFP was to do my changes there, creating prgs that work on a copy of of my VFP data, doing ALTER TABLE commands to add fields, copy data, transform data, allow null, generate integer keys etc.



The I pointed Full Convert at that and it moved it to SQL without a hitch.



And if I found something I didn't like I could tweak the prg, tweak the Full convert project, then blow away the SQL database, recreate it from DDT and rerun the process.



Suppose I could have done it with remote views but that turned out to be a lot more work.
Howard Bennett
Howard Bennett
StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)
Group: Forum Members
Posts: 57, Visits: 496
Thanks for the advice!



I've got most of the structure setup in DDT and will be finishing that up this week - then on to moving the data. I'll be coding all that as there are some significant structure changes and I won't be able just to move data with a third party product. Should be fun!



It's good to know there are people who've done this and that I can come back here for help!



HB
Michel Levy
Michel Levy
StrataFrame User (441 reputation)StrataFrame User (441 reputation)StrataFrame User (441 reputation)StrataFrame User (441 reputation)StrataFrame User (441 reputation)StrataFrame User (441 reputation)StrataFrame User (441 reputation)StrataFrame User (441 reputation)StrataFrame User (441 reputation)
Group: StrataFrame Users
Posts: 193, Visits: 9K
I'm an old fox developer, and here's the way I use for migrating VFP to SQL (in addition to Charles, who is also an old fox).

First of all, migrate structure.

I use VFP9 Upsizing Wizard to migrate structure, because my dbfs are allways referenced in a dbc, and RI is implemented with its triggers - I had corrected a few bugs in its sources in order to manage varchar(max), and varbinary(max), but it seems that Rick Schummer's version is now without bug.
Upsizing wizard allows to add Timestamp fields (they are usefull for a good concurency management), and creates referential integrity in a declarative way (creates constraints, and not triggers).

Then, I use DDT on the new structure, on SQL server. I'found that way more simple than importing VFP structure from within DDT, but it is probably because I use VFP upsizing wizard for many years (and DDT only 2 years).

once your structure is ok in SQL, let you migrate data. Never use VFP uspizing wizard for that! never!

Before data transfer, check and check again the quality of your data, never forget that VFP is a lazzy language and a fuzzy storage (that's why VFP developpers may not be lazzy or fuzzy, and I love VFP Kiss , but I know its bugs). For exemple, in VFP, a field N(5,2) should hold nothing larger than 99.99 Try it, and you will see that you can store whatever bigger value you want, and the fox will not raise any error.
But when you try to transfer this row in a SQL table, you'll get a splendid crash Blink (I still remember the first time I got it: more than a week in debugging to find it, and write this tiny prg to detect it in all dbfs)

With my customers, I use 2 ways to transfer data. Some prefers to push data from VFP into SQL, using remote views in Fox. Others use importing wizard in SSMS (wich in fact uses SSIS). I've tried using dbfs as a linked server in SQL, it runs without problem, but is slower than SSIS.

Don't worry about null, but check VFP specific syntax in default values and validation rules in dbf.

And enjoy SQL and StrataFrame !

Howard Bennett
Howard Bennett
StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)
Group: Forum Members
Posts: 57, Visits: 496
Thanks to both of you! I think I've got enough to make a determination as to which way to go...



I'm sure I'll be back SOON!



HB
Russell Scott Brown
Russell Scott Brown
StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)
Group: Forum Members
Posts: 124, Visits: 597
Thanks Charles.  Full Convert is definitely something I am going to need in a few months when I get to converting all my VFP tables.

This is going to save me huge amounts of time and headaches.

Russ Brown (Using C#2010/SQL Server 2008)

Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
Full Convert moves the data for you from VFP to SQL - that's what it's for - so there is no writing code to move the data. All you have to do is replace blank dates with nulls before moving.



You pretty much have to allow nulls for the empty dates, unless you want to replace them with {01/01/1800}. But you don't really need to worry about the nulls. The Microfour folks deal with huge datatables and have a lot of performance issues they tweak constantly so there may be some advantage to avoiding them altogether, but for most first time VFP to SF/SQL conversions I'd bet the nulls are not going to be an issue. If so, you can always massage the converted data on the sql side and then change the structure with DDT to close down future nulls.



If your data already has nulls in it, you don't really need to fill them with anything. Just make sure your DDT structure allows for nulls.



Basically the easiest path is to first import your VFP structure into DDT. In DDT make any changes you want to fieldnames, types etc. You can delete the change history in DDT since you are not going to be updating an existing SQL database.



Then write that DDT schema to your SQL database so now you have empty SQL structures that looks the way you want them for your SF/SQL app.







Now use FullConvert to move the data from VFP tables to SQL tables.



From that point on, only change the SQL structure through the DDT.



If you are going to setup any default values on the backend ( autoincrement integer pks for example ) do it through the DDT. I'd recommend at first using backend defaults only for those PKs. I think the rest (a date that defaults to today() etc ) is better handled in the BOs



Just make sure you save your Full Contact project so you can export to sql, play with it, and then export production data for real when you know you have the conversion the way you want it.



Default values :



Two things - the BOMapper handles what to do with null values, not inserting defaults in a new record. It is an issue of translating how the BO will get data from the back end. So if a date is null, what do i send to the control (#1/1/1800#) The control knows how to look at that and show and empty date in the control.



The "default" values of the BO is something like :



In a new record, the State with default to "NY", the EnteredDate with default to Now() etc.



That is handled in the EventHandlers region of the BO :



'''

''' Sets the default values for a new row

'''


'''

Private Sub PropCoverageBO_SetDefaultValues()

me.State = "NY"

me.EnteredDate = Now()

End Sub






The BO stuff is in the BO partial class that you don't manually edit for the strongly type field properties :



'''

''' This field was imported.

'''



BusinessFieldDisplayInEditor(), _

Description("This field was imported."), _

DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _

Public Property [EXPIREDATE]() As System.DateTime

Get

Dim loValue As Object

loValue = Me.CurrentRow.Item("EXPIREDATE")

If loValue Is DBNull.Value Then

Return #1/1/1800#

Else

Return CType(loValue, System.DateTime)

End If

End Get

Set(ByVal value As System.DateTime)

If value <> #1/1/1800# Then

Me.CurrentRow.Item("EXPIREDATE") = value

Else

Me.CurrentRow.Item("EXPIREDATE") = DBNull.Value

End If

End Set

End Property






Notice the null on the backend becomes a "date" the control knows to treat as empty, then if you leave it empty, it sends a null to the back end.



GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search