0

I'm trying to backup my database through ODBC with vb.net but can't find a way.
Some of many approaches:

        Try
            btCommand = New OdbcCommand("pg_dump '" + mydatabase + "' > 'all.sql'", mCon)
            'OR
            ' btCommand = New OdbcCommand("BACKUP DATABASE '" + mydatabase + "',  'all.sql'", mCon)
            btCommand.ExecuteNonQuery()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly)
        End Try

But no one works. Please advice on how to do this.

1 Answer 1

3

pg_dump is a command line executable, not a SQL command.

There are many different options for backing up a PostgreSQL database system. You should probably read through the documentation to see which one is the best fit for you.

Sign up to request clarification or add additional context in comments.

3 Comments

After reading, still can't find or don't understand usable way for backing up through odbc command. Any closer recommendation?
You could try to emulate what pg_dump does by running a lot COPY statements and such, but why not use one of the tools already written and available? Surely you have some way to access the database besides ODBC?
Yes, I can access (and backup) my database by few ways. I can also shell from my program to pg_dump.exe. But I am just curious if here becomes some totally programatic way covered by ODBC. Never mind if not. Thanks for helping!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.