Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calling SQL SERVER backup & restore fro VFP
Message
 
To
07/07/2006 15:35:09
Stephen Hunt
Admit Computer Services Inc.
Farmingdale, New York, United States
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01134436
Message ID:
01134786
Views:
18
>Ok the backup works ! Thanks ! Now I am trying to do the restore but it tells me that the database is in use, so I tried an SQLDISCONNECT() then SQLEXEC() to run the restore but I know longer have a connection handle to send with the SQLEXEC(). Is there anyway to attach to the database without actually opening it ?
>
>Thanks Again for all your help !
>Stephen J. Hunt

You can attach database, but restore and attach are two different things.
To restore your database you must be sure that thare are no current connections to DataBase. If your connection string includes "
;DataBase=MyDataBase, just remove that string from your connection string. You could connect directly to SQL Server w/o using DataBase name. Here what you must do, before restore your DataBase:
SQLDISCONNECT(CurrentSqlHandler)
RestoreSqlHandler = SQLSTRINGCONNECT([Driver={SQL Server};Server=YourServerName;Uid=USERNAME;Pwd=PASSWORD;])
** Or for trusted connection: RestoreSqlHandler = SQLSTRINGCONNECT([Driver={SQL Server};Server=YourServerName;Trusted_Connection=yes;])

IF SQLEXEC(RestoreSqlHandler,[ restore string here]) < 0
   AERROR(laError)
   MessageBox([Restore is not successful ]+laError[1,2])
ENDIF
SQLDISCONNECT(RestoreSqlHandler)

CurrentSqlHandler = SQLSTRINGCONNECT([Driver={SQL Server};Server=YourServerName;Uid=USERNAME;Pwd=PASSWORD;DataBase=YourDataBase])
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Reply
Map
View

Click here to load this message in the networking platform