Monday, February 20, 2012

Is there any API to browse for folder on SQL Server's machine?

Hi!
I know there is xp_dirtree, xp_subdirs, xp_fixeddrives procedures which
allows me to implement a folder select dialog.
But SQL Server's Enterprise Manager already has such dialog. For example
if you open "Attach Database"
dialog and then press browse [...] button Enterprise Manager will show you
"Browse For Existing File" dialog. And
as you can see all the path information in that dialog is local to SQL
Server's machine. This is what
SHBrowseForFolder cannot do for you because SHBrowseForFolder always shows
paths relative to local machine.
My question is: Is there any way to reuse that Enterprise Manager's
"Browse For Existing File" dialog? Or I am
obliged to reinvent it?Hi,
You need to re-invent it using the xp's you mentioned
Greg O
"Igor Solodovnikov" <IgorSolodovnikov@.discussions.microsoft.com> wrote in
message news:op.suy1vyq7n8ihmu@.iw2k.helpmicro.local...
> Hi!
> I know there is xp_dirtree, xp_subdirs, xp_fixeddrives procedures which
> allows me to implement a folder select dialog.
> But SQL Server's Enterprise Manager already has such dialog. For example
> if you open "Attach Database"
> dialog and then press browse [...] button Enterprise Manager will show you
> "Browse For Existing File" dialog. And
> as you can see all the path information in that dialog is local to SQL
> Server's machine. This is what
> SHBrowseForFolder cannot do for you because SHBrowseForFolder always shows
> paths relative to local machine.
> My question is: Is there any way to reuse that Enterprise Manager's
> "Browse For Existing File" dialog? Or I am
> obliged to reinvent it?|||Hi
If you use SQL profiler to check out what EM is doing you will see the same
procedures being called!
John
"Igor Solodovnikov" wrote:

> Hi!
> I know there is xp_dirtree, xp_subdirs, xp_fixeddrives procedures which
> allows me to implement a folder select dialog.
> But SQL Server's Enterprise Manager already has such dialog. For example
> if you open "Attach Database"
> dialog and then press browse [...] button Enterprise Manager will show you
> "Browse For Existing File" dialog. And
> as you can see all the path information in that dialog is local to SQL
> Server's machine. This is what
> SHBrowseForFolder cannot do for you because SHBrowseForFolder always shows
> paths relative to local machine.
> My question is: Is there any way to reuse that Enterprise Manager's
> "Browse For Existing File" dialog? Or I am
> obliged to reinvent it?
>|||You could look into the SQL-NS API (where NS stands for Name Space). The API
exposes most of EM
dialogs as COM objects, I'm not sure about the file browsing dialogs, though
. It is not
re-distributable, though. This means that the client machine need the SQL Se
rver tools (EM)
installed to run your app. And it will not be carried forward to SQL Server
2005.
Two other alternatives:
Use the undocumented xp's you mention. Downside is that they are undocumente
d, unsupported etc.
Use xp_cmdshell and DIR etc. Harder to interpret the result (a table with on
e column, so some string
parsing is needed).
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Igor Solodovnikov" <IgorSolodovnikov@.discussions.microsoft.com> wrote in me
ssage
news:op.suy1vyq7n8ihmu@.iw2k.helpmicro.local...
> Hi!
> I know there is xp_dirtree, xp_subdirs, xp_fixeddrives procedures which a
llows me to implement a
> folder select dialog.
> But SQL Server's Enterprise Manager already has such dialog. For example
if you open "Attach
> Database"
> dialog and then press browse [...] button Enterprise Manager will show you "Br
owse For Existing
> File" dialog. And
> as you can see all the path information in that dialog is local to SQL Se
rver's machine. This is
> what
> SHBrowseForFolder cannot do for you because SHBrowseForFolder always shows
paths relative to
> local machine.
> My question is: Is there any way to reuse that Enterprise Manager's "Brow
se For Existing File"
> dialog? Or I am
> obliged to reinvent it?|||> You could look into the SQL-NS API (where NS stands for Name Space). The
> API exposes most of EM dialogs as COM objects, I'm not sure about the
> file browsing dialogs, though. It is not re-distributable, though. This
> means that the client machine need the SQL Server tools (EM) installed
> to run your app. And it will not be carried forward to SQL Server 2005.
Thank you for this information. I will loo into SQL-NS

> Two other alternatives:
> Use the undocumented xp's you mention. Downside is that they are
> undocumented, unsupported etc.
And another downside: i need to spend significant time to implement and
debug that dialog. :(

No comments:

Post a Comment