Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Refreshing SQL Database
Message
De
23/02/2005 04:31:27
Jon Neale
Bond International Software
Wootton Bassett, Royaume Uni
 
 
À
23/02/2005 04:30:43
Jon Neale
Bond International Software
Wootton Bassett, Royaume Uni
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Versions des environnements
Visual FoxPro:
VFP 8 SP1
Divers
Thread ID:
00989076
Message ID:
00989525
Vues:
25
Forgot to say you will have to make a master backup of your data first.

>Hi James,
>
>I have done this by creating an Stored Procedure in SQL and then call this SP from VFP.
>
>Run this in Query Analyser against Master.
>----------------------------------------
>CREATE PROCEDURE resetdata
> @dbname varchar(20),
> @filename varchar(80)
>AS
>
>RESTORE DATABASE @dbname FROM DISK = @filename
>----------------------------------------
>
>To call it form VFP do something similar to below;
>--------------------------------------------
>lcConnectString = "driver=SQL Server;server=ISC34;uid=sa;pwd=jon;Database=master;app='';Encrypt='';"
>lnConnectHandle = SQLSTRINGCONNECT(lcConnectString)
>
>cDatabase = "PPWin"
>cLocation = "c:\tmp\PPWin.Bak"
>
>lnresult = Sqlexec(lnConnectHandle, [EXEC resetdata ?cDatabase, ?cLocation])
>if lnresult < 0
> messagebox("Error Occurred with restore")
>else
> messagebox("Restore Complete")
>endif
>----------------------------------------------
>
>
>You will need to change parts of this to make it work for you, but I hope it gives you an idea of how you can do it.
>
>I'm not sure if creating the SP against master is a good idea (my knowledge of SQL is limited) but this does work.
>
>Maybe somebody else can advise me on this?
>
>Hope this helps you.
>
>Jon
>
>
>>Yes, I want to restore the database before each module is called. But how do I do it at run time (I mean, programmatically)?
>>
>>> Are you saying that each time a test program (module) runs it may effect the data from the database, therefore you would like to be able to start each module against an original (reliable) dataset?
>>
>>> If so then you could look at restoring the database each time before each module is called. A bit heavy handed, if you know which tables have been effected you could just import the tables from a "Master" copy of the data.
>>
>>> Your thoughts?
>>
>>> Jon
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform