Microsoft KB Archive/173878: Difference between revisions
m (Text replacement - ">" to ">") |
m (Text replacement - """ to """) |
||
Line 44: | Line 44: | ||
== SYMPTOMS == | == SYMPTOMS == | ||
Moving a project that contains tables to a different drive clears the | Moving a project that contains tables to a different drive clears the "Map field type to classes" information for the tables. | ||
</div> | </div> | ||
Line 61: | Line 61: | ||
if ( pcount() = 1 ) | if ( pcount() = 1 ) | ||
if ( lower( getenv( | if ( lower( getenv( "Machine" ) ) == "dfsd pentium" ) | ||
lcFromDrive = | lcFromDrive = "e" &&Drive where project originally located. | ||
lcToDrive = | lcToDrive = "h" &&Drive where project is moved to. | ||
else | else | ||
lcFromDrive = | lcFromDrive = "h" &&Drive where project originally located. | ||
lcToDrive = | lcToDrive = "e" &&Drive where project is moved to. | ||
endif | endif | ||
endif | endif | ||
lcFromDrive = lower( lcFromDrive ) + | lcFromDrive = lower( lcFromDrive ) + ":\" | ||
lcToDrive = lower( lcToDrive ) + | lcToDrive = lower( lcToDrive ) + ":\" | ||
use (lcDBC + | use (lcDBC + ".dbc") | ||
scan for objecttype = | scan for objecttype = "Field" | ||
if ( at( lcFromDrive, Property ) > 0 ) | if ( at( lcFromDrive, Property ) > 0 ) | ||
replace property with strtran( property, lcFromDrive, lcToDrive ) | replace property with strtran( property, lcFromDrive, lcToDrive ) | ||
Line 85: | Line 85: | ||
After you move the Project directory, for example from C:\VFPApp to D:\VFPApp, run Visual FoxPro and type the following commands in the command window: | After you move the Project directory, for example from C:\VFPApp to D:\VFPApp, run Visual FoxPro and type the following commands in the command window: | ||
<pre class="codesample"> SET DEFAULT TO d:\VFPApp | <pre class="codesample"> SET DEFAULT TO d:\VFPApp | ||
movedbc( | movedbc("qa","c","d") | ||
</pre> | </pre> | ||
Now when you open the project and then modify the table, you will not get the error message, and the Field mapping information will be retained. | Now when you open the project and then modify the table, you will not get the error message, and the Field mapping information will be retained. | ||
Line 101: | Line 101: | ||
== MORE INFORMATION == | == MORE INFORMATION == | ||
If a table is part of a database, then you can map a class library and a class to each of the fields in the table using the | If a table is part of a database, then you can map a class library and a class to each of the fields in the table using the "Map field type to Classes" option in the Table Designer. This way you specify the class you want to create when you drag the field onto a form. If all these files (database, table, class library) are a part of a project and the project is moved to a different drive (for example, from drive "C:" to drive "D:"), then modifying a table within the project that had a field mapped to a class will produce "The Class.... Associated with this field cannot be found - class association is cleared" error message, and the Field Mapping information is cleared. | ||
=== Steps to Reproduce Behavior === | === Steps to Reproduce Behavior === | ||
<ol> | <ol> | ||
<li><p>Using the Windows Explorer to create a directory | <li><p>Using the Windows Explorer to create a directory "c:\vfp5app", or from Visual FoxPro type the following command:</p> | ||
<pre class="codesample"> MD c:\vfp5app</pre></li> | <pre class="codesample"> MD c:\vfp5app</pre></li> | ||
<li><p>In the directory you created in the previous step, create a class library and class by issuing the following commands from the Visual FoxPro Command window:</p> | <li><p>In the directory you created in the previous step, create a class library and class by issuing the following commands from the Visual FoxPro Command window:</p> | ||
Line 111: | Line 111: | ||
CREATE CLASS ctextbox OF ccontrols AS TextBox</pre></li> | CREATE CLASS ctextbox OF ccontrols AS TextBox</pre></li> | ||
<li>Save the class and close the Class Designer.</li> | <li>Save the class and close the Class Designer.</li> | ||
<li><p>Create a project, database, and table in the | <li><p>Create a project, database, and table in the "c:\vfp5app\" directory and name all three of them "QA" with the following commands:</p> | ||
<pre class="codesample"> CREATE PROJECT c:\vfp5app\qa | <pre class="codesample"> CREATE PROJECT c:\vfp5app\qa | ||
CREATE DATABASE c:\vfp5app\qa | CREATE DATABASE c:\vfp5app\qa | ||
Line 117: | Line 117: | ||
</pre> | </pre> | ||
<p>Make sure that the database is open and active when you create the table so that the table is added to it.</p></li> | <p>Make sure that the database is open and active when you create the table so that the table is added to it.</p></li> | ||
<li>Add the | <li>Add the "QA" database and the class library, created in the previous step, to the "QA" project.</li> | ||
<li>Open the | <li>Open the "QA" project. From the Project Manager, modify table "QA". When the table designer appears, click the Fields tab.</li> | ||
<li>Select | <li>Select "iID" field, and then under the "Map Field type to Classes" section set "Display Library" to "C:\vfp5app\ccontrols.vcx" and "Display Class" to "cTextBox". Do the same for the "cText" field.</li> | ||
<li>Close the Table Designer and the project.</li> | <li>Close the Table Designer and the project.</li> | ||
<li>Using the Windows Explorer, MOVE the whole project, including all the files, to another drive, for example | <li>Using the Windows Explorer, MOVE the whole project, including all the files, to another drive, for example "D:" or "E:", with the same directory structure (D:\vfp5app\ or E:\vfp5app).</li> | ||
<li>Open the project.</li> | <li>Open the project.</li> | ||
<li>Modify table | <li>Modify table "QA".</li> | ||
<li>When the | <li>When the "The Class.... Associated with this field cannot be found - class association is cleared" error message is displayed, click OK.</li> | ||
<li>When the Table designer appears, click the Fields Tab and look at the | <li>When the Table designer appears, click the Fields Tab and look at the "Map Field type to Classes" section for each of the fields. Note that both the "Display Library" and "Display Class" properties are blank.</li></ol> | ||
NOTE: Rebuilding the project does not resolve this problem. | NOTE: Rebuilding the project does not resolve this problem. |
Revision as of 11:07, 21 July 2020
Article ID: 173878
Article Last Modified on 12/11/1999
APPLIES TO
- Microsoft Visual FoxPro 5.0a
This article was previously published under Q173878
SYMPTOMS
Moving a project that contains tables to a different drive clears the "Map field type to classes" information for the tables.
RESOLUTION
To workaround the problem place the following code in a Visual Foxpro program file:
Sample Code
PARAMETERS lcDBC, lcFromDrive, lcToDrive &&lcDBC = Database Container in the project. &&lcFromDrive = The drive where the project was originally. &&lcToDrive = The drive where the project is moved to. if ( pcount() = 1 ) if ( lower( getenv( "Machine" ) ) == "dfsd pentium" ) lcFromDrive = "e" &&Drive where project originally located. lcToDrive = "h" &&Drive where project is moved to. else lcFromDrive = "h" &&Drive where project originally located. lcToDrive = "e" &&Drive where project is moved to. endif endif lcFromDrive = lower( lcFromDrive ) + ":\" lcToDrive = lower( lcToDrive ) + ":\" use (lcDBC + ".dbc") scan for objecttype = "Field" if ( at( lcFromDrive, Property ) > 0 ) replace property with strtran( property, lcFromDrive, lcToDrive ) endif endscan use
Save the file, in the project directory (VFPApp), as movedbc.prg.
After you move the Project directory, for example from C:\VFPApp to D:\VFPApp, run Visual FoxPro and type the following commands in the command window:
SET DEFAULT TO d:\VFPApp movedbc("qa","c","d")
Now when you open the project and then modify the table, you will not get the error message, and the Field mapping information will be retained.
STATUS
Microsoft is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATION
If a table is part of a database, then you can map a class library and a class to each of the fields in the table using the "Map field type to Classes" option in the Table Designer. This way you specify the class you want to create when you drag the field onto a form. If all these files (database, table, class library) are a part of a project and the project is moved to a different drive (for example, from drive "C:" to drive "D:"), then modifying a table within the project that had a field mapped to a class will produce "The Class.... Associated with this field cannot be found - class association is cleared" error message, and the Field Mapping information is cleared.
Steps to Reproduce Behavior
Using the Windows Explorer to create a directory "c:\vfp5app", or from Visual FoxPro type the following command:
MD c:\vfp5app
In the directory you created in the previous step, create a class library and class by issuing the following commands from the Visual FoxPro Command window:
CREATE CLASSLIB C:\vfp5app\ccontrols.vcx CREATE CLASS ctextbox OF ccontrols AS TextBox
- Save the class and close the Class Designer.
Create a project, database, and table in the "c:\vfp5app\" directory and name all three of them "QA" with the following commands:
CREATE PROJECT c:\vfp5app\qa CREATE DATABASE c:\vfp5app\qa CREATE TABLE qa ( iID i, cText c(10) )
Make sure that the database is open and active when you create the table so that the table is added to it.
- Add the "QA" database and the class library, created in the previous step, to the "QA" project.
- Open the "QA" project. From the Project Manager, modify table "QA". When the table designer appears, click the Fields tab.
- Select "iID" field, and then under the "Map Field type to Classes" section set "Display Library" to "C:\vfp5app\ccontrols.vcx" and "Display Class" to "cTextBox". Do the same for the "cText" field.
- Close the Table Designer and the project.
- Using the Windows Explorer, MOVE the whole project, including all the files, to another drive, for example "D:" or "E:", with the same directory structure (D:\vfp5app\ or E:\vfp5app).
- Open the project.
- Modify table "QA".
- When the "The Class.... Associated with this field cannot be found - class association is cleared" error message is displayed, click OK.
- When the Table designer appears, click the Fields Tab and look at the "Map Field type to Classes" section for each of the fields. Note that both the "Display Library" and "Display Class" properties are blank.
NOTE: Rebuilding the project does not resolve this problem.
Keywords: kbprb KB173878