Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Functionality similar to C#'s Backup.SqlBackup()
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Functionality similar to C#'s Backup.SqlBackup()

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    d2uriel
    wrote on last edited by
    #1

    Dear Qt programmers,

    I have an application that I wrote in C# and it uses "this":http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.backup.sqlbackup.aspx#Y0 specific method. It creates a backup of a MSSQL database. I wanted to port that app to Qt enabled C++ (which is more platform independent ;-) ). I've searched the forums and Googled for it and found nothing relevant - does Qt provide anything similar to this functionality? I need to be able to make a backup which can afterwards be restored using Management Studio for MSSQL Server or a similar piece of software.

    DBMS used is MSDE 2000 or MSSQL 2008.

    Thank you in advance for your suggestions.

    Daniel.

    Edit: Not possible in Qt, but you can use osql.exe and start it within Qt if you like.

    "Do not judge, and you will never be mistaken." - Jean-Jacques Rousseau

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      That's more a C/C++ question on Windows API. From Qt's side, there is no support for it, but you can use whatever C/C++ API you want in Qt based applications. It's still C/C++ :-)

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • D Offline
        D Offline
        d2uriel
        wrote on last edited by
        #3

        Thanks Volker for your answer. I'm trying to create this backup using osql.exe application that is delivered with MSDE2000 and QProcess.

        Here's the code snippet:
        @
        QProcess *dbBackupProcess = new QProcess();
        QStringList args; args << "-Uuser" << "-Ppassword" << "-Sdomain\SQLinstance" << "-Q "BACKUP DATABASE dbName TO DISK = 'E:\backupName.bak'"";
        dbBackupProcess->start("osql.exe", args);
        @

        This unfortunately doesn't work. What am I doing wrong?

        Below command ran from the command prompt works good:
        @osql.exe -Uuser -Ppassword -Sdomain\SQLinstance -Q "BACKUP DATABASE dbName TO DISK = 'E:\backupName.bak'"@

        Edit: Okay, never mind. I'm finally getting somewhere. Will post an update soon.

        Edit#2: I guess I solved it:

        @
        QString command = "osql.exe -UuserName -Ppassword -Sdomain\SQLinstance -Q "BACKUP DATABASE dbName TO DISK = 'E:\backupName.bak'"";
        int exitCode = QProcess::execute(command);
        @

        "Do not judge, and you will never be mistaken." - Jean-Jacques Rousseau

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved