Board index » delphi » Getting Server Name from DataLink

Getting Server Name from DataLink

I need to get the Name of  the server for which the Datalink is connected
to.
I tried using the ADOConnection.ConnectionString but don't know how to
Access the specific ServerName. Is there an easy way to extract this from
the component or else from the udl file?

Thanks in advance

Stephen K. Miyasato

 

Re:Getting Server Name from DataLink


Quote
>I tried using the ADOConnection.ConnectionString but don't know how to
>Access the specific ServerName. Is there an easy way to extract this from
>the component or else from the udl file?

Search the connection string for ';Data Source='   everything between the = sign
and the next semi colon to the right will be the name of the server.

This is not tested but should give you some code to start with

var
  st:string;
i:integer
begin
   i:= Pos('Data Source=',TadoConnection.ConnectionString);
  st:= Copy(TadoConnection.ConnectionString,i,100)
  if Pos(st,';')> 0 then
     st:= Copy(st,1,Pos(st,';')-1);

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Getting Server Name from DataLink


Brian

Just what I was looking for

Thanks again,

Stephen
"Brian Bushay TeamB" <BBus...@Nmpls.com> wrote in message
news:o0fpet0gsi8969mueg451io07rqdm7fvsh@4ax.com...

Quote

> >I tried using the ADOConnection.ConnectionString but don't know how to
> >Access the specific ServerName. Is there an easy way to extract this from
> >the component or else from the udl file?

> Search the connection string for ';Data Source='   everything between the
= sign
> and the next semi colon to the right will be the name of the server.

> This is not tested but should give you some code to start with

> var
>   st:string;
> i:integer
> begin
>    i:= Pos('Data Source=',TadoConnection.ConnectionString);
>   st:= Copy(TadoConnection.ConnectionString,i,100)
>   if Pos(st,';')> 0 then
>      st:= Copy(st,1,Pos(st,';')-1);

> --
> Brian Bushay (TeamB)
> Bbus...@NMPLS.com

Other Threads