Monday, 26 August 2013

call postgresql pg_dump.exe from visual basic

call postgresql pg_dump.exe from visual basic

Im trying to do a backup of my database from my application made in visual
basic (visual studio 2012)
I copy the pg_dump.exe with the necessary dll files to the application root.
Test the pg_dump doing a backup from cmd window and goes ok
This is the code i use to try to call the pg_dump exe but apparently does
not receive the parameters i'm trying to send.
' New ProcessStartInfo created
Dim p As New ProcessStartInfo
Dim args As String = "-h serverip -p 5432 -U postgres db_name > " &
txtPath.Text.ToString
' Specify the location of the binary
p.FileName = "pg_dump.exe"
' Use these arguments for the process
p.Arguments = args
' Use a hidden window
p.WindowStyle = ProcessWindowStyle.Maximized
' Start the process
Process.Start(p)
When the process start i get this msg:
pd_dump: too many command-line arguments (first is ">") Try "pg_dump
--help" for more information
if i type this in cmd the backup is done ok pg_dump.exe -h serverip -p
5432 -U postgres db_name > c:\db_bak.backup
But i cant make it work from visual.

No comments:

Post a Comment