VB6 Restoring --cannot continue with data restore

  • Hi,

    I get this error when trying to restore from a file

    "cannot continue with data restore! please read tutorial for the

    right installation of the system"

    I connect to the database using windows authentication (with

    administrative privileges) --> dbowner

    This is the code I used is

    Set db = New Connection

    db.CursorLocation = adUseClient

    db.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist

    Security Info=False;Initial Catalog=gendb;Data

    Source=(LOCAL)\myserver;"

    db.Execute "restore database gendb from disk='" + filename + "'"

    The backup function did NOT generate an error (db.Execute "backup

    database gendb...")

    I only want to restore the gendb database (not the logins dts etc).

    What could I be doing wrong? I have done it with Enterprise manager but

    the program I'm enhancing needs that functionality

    Thanks in advance

  • It would appear as if you are connecting to the gendb database (Initial Catalog=gendb)  when you attempt to restore the gendb database.  So that means that you expect the database to already be there?

    Look at the restore command in SQL Books Online.  It will explain the options that you need to use in order to do what you want.

    Probably, change the Initial Catalog to master in the connection string.

    Then replace all but the last character in your db.Execute with:

    [space]WITH REPLACE"

    jg

     

  • Thanks for the reply... Yes you're right I forgot to change the database to master.

    The db connection (single instance for the whole app) needs to default to gendb)

    I changed the code to this and it worked

    db.execute "use master restore databse gendb from disk=<path>"

    I only included the "with" part to change the database to restore to (if the user wants to restore it to a different database name (ie create new database and restore data there)

    Thanks again for the reply. Hehehe I just tend to overlook simple things hehehe

     

     

     

     

  • Excellent rj.  Glad I could help.  The simple things are often the hardest to see.

    jg

     

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply