Archives

Great Links

Manually Deleting a Database in M2M

I am a big fan of using practice companies in M2M, which allow users to experiment with M2M while not creating problems in production. However, occasionally M2M will not properly delete a company when it is no longer needed.

Recently this happened again, so I thought I would document the process of manually deleting a company for anyone with a similar problem. I need to be clear on one point. I am not suggesting you manually delete companies just because you can. Always attempt to use M2M to properly delete practice companies first. If that should fail however, you can use the following. This would be a good place to include my standard Disclaimer.

Important: All information on this site is provided “as is” for informational purposes only.
In particular, all code samples are provided “as is” without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

If you should decide to use any of the code from this site, make sure you test it thoroughly on a test company (or better yet a test server) before you ever use it on your live data.

Perform the following steps:

Make a back up of your UTIL folder by simply copying it elsewhere in Windows explorer. Make sure ALL users are out of m2m including any non-user accounts such as bar coding.

Open SQL Enterprise Manager and locate the database you wish to delete. Right click on it and select delete.

If you have backups for the practice company you must delete them as well. You can locate them through Windows Explorer.

Open Visual FoxPro and enter the following.

set excl onopendata X:\m2mdata\util\util &&Replace X with your mapped drive.
delete conn && This will delete your connection string. See picture below.
use UTCOMP excl
brow &&Select the appropriate database record and mark it for deletion by clicking the small rectangle to the left.
PackCloseAll

set excl on
open data X:\m2mdata\util\util && Replace X with your mapped drive.
delete conn && This will delete your connection string. See picture below.
use UTCOMP excl
brow && Select the appropriate database record and mark it for deletion by clicking the small rectangle to the left.
Pack
Close All

If you neglect the delete conn step, you will receive an error message: -1 could not update system database. I mention this specifically because I often forget this step.

There are also user access records related to the company you need to delete in UTACC table. Enter the following into VFP:

use utacc excl
deletefor fccompid='XX'&&Replace ‘XX’ with the company number you wish todelete.
PackCloseAll

use utacc excl
delete for fccompid='XX' && Replace ‘XX’ with the company number you wish to delete.
Pack
Close All

Navigate to x:\m2mdata\data00\loading where x is your mapped drive and run createdbc. Select your live company from the top portion. Important: You must select the option “Rebuild System DB Connection” to rebuild your UTIL connection string. Remember to repeat createbc for each remaining company.