locked
How to select a server side folder path when backup SQL server database using SMO? RRS feed

  • Question

  • Hi,

    I'd like to implement a folder select dialog when backup database using SMO since SMO can only store the backup file in the server side's  local disk.  The SQL server management studio has alredy used it :

    So,how can i get the server side folder structure or how can i use C# to open a folder select dialog like that?


    Johnny
    • Edited by Johnny Qian Saturday, October 15, 2011 6:58 AM
    Saturday, October 15, 2011 5:57 AM

Answers

  • It is related to SQL Server forums, however I answer it here.

    I give you the keys and you do the rest....

    You should use the following  stored procedures to browse drives and folders. and finally show them in a tree view control.

    xp_fixeddrives : A stored procedure to get fixed drives

    xp_availablemedia : A stored procedure to get available drives

    xp_dirtree : A stored procedure to get sub directories (tree structure with depth)

     

    Usage:

    master..xp_fixeddrives   ==> it gives you hard disk drives

    master..xp_dirtree "c:\windows"  ==> it gives you folders under windows folder

     

    See also:

    http://social.msdn.microsoft.com/Forums/en/sqlsmoanddmo/thread/8b7c6c44-49e3-420c-a0e0-8f9d9975cd05

     


    If this post answers your question, please click "Mark As Answer". If this post is helpful please click "Mark as Helpful".
    My blog: http://csharptips.wordpress.com
    • Edited by Alan Zavari Sunday, October 16, 2011 2:16 PM
    • Marked as answer by Johnny Qian Sunday, October 16, 2011 3:08 PM
    Saturday, October 15, 2011 1:37 PM

All replies

  • It is related to SQL Server forums, however I answer it here.

    I give you the keys and you do the rest....

    You should use the following  stored procedures to browse drives and folders. and finally show them in a tree view control.

    xp_fixeddrives : A stored procedure to get fixed drives

    xp_availablemedia : A stored procedure to get available drives

    xp_dirtree : A stored procedure to get sub directories (tree structure with depth)

     

    Usage:

    master..xp_fixeddrives   ==> it gives you hard disk drives

    master..xp_dirtree "c:\windows"  ==> it gives you folders under windows folder

     

    See also:

    http://social.msdn.microsoft.com/Forums/en/sqlsmoanddmo/thread/8b7c6c44-49e3-420c-a0e0-8f9d9975cd05

     


    If this post answers your question, please click "Mark As Answer". If this post is helpful please click "Mark as Helpful".
    My blog: http://csharptips.wordpress.com
    • Edited by Alan Zavari Sunday, October 16, 2011 2:16 PM
    • Marked as answer by Johnny Qian Sunday, October 16, 2011 3:08 PM
    Saturday, October 15, 2011 1:37 PM
  • Maybe you can think of using the sqlcommand object combine with SQL backup command

    http://msdn.microsoft.com/en-us/library/ms186865(v=SQL.90).aspx

    chanmm


    chanmm
    Sunday, October 16, 2011 3:56 AM
  • Thank you so much, Abdollah!That's what i expect.
    Johnny
    Sunday, October 16, 2011 3:08 PM