Board index » delphi » How to login to an MsSQL Server though a BDE TDatabase

How to login to an MsSQL Server though a BDE TDatabase

Hi there,

I'm trying to login programatically to an SQL I Have a TDatabase Object
which uses the AliasName property to
get the conection values and then I sustitute the "USER NAME" and
"PASSWORD" Values with the next code:

  Ix = dbIsxml->Params->IndexOfName("USER NAME");
  if ( Ix >= 0 )
     {
       sData = frmMain->getUserName();
       dbIsxml->Params->Values[ Ix ] = sData;
       sData = dbIsxml->Params->Values[ Ix ];

       Ix    = dbIsxml->Params->IndexOfName("PASSWORD");
       sData = frmMain->getUserName();
       dbIsxml->Params->Values[ Ix ] = sData;
       sData = dbIsxml->Params->Values[ Ix ];
     }
  else
     {
       Ix = dbIsxml->Params->Add("USER NAME");
       sData = frmMain->getUserName();
       dbIsxml->Params->Values[ Ix ] = sData;
       sData = dbIsxml->Params->Values[ Ix ];
     }

  Ix = dbIsxml->Params->IndexOfName("PASSWORD");
  if ( Ix >= 0 )
     {
       sData = frmMain->getUserName();
       dbIsxml->Params->Values[ Ix ] = sData;
       sData = dbIsxml->Params->Values[ Ix ];
     }
  else
     {
       Ix = dbIsxml->Params->Add("PASSWORD");
       sData = frmMain->getUserName();
       dbIsxml->Params->Values[ Ix ] = sData;
       sData = dbIsxml->Params->Values[ Ix ];
     }

But it alway return an "Invalid user or password" error If I put
staticlly the parameters editing the TDatabase Properties it works.

Does anyone have any idea ?

 

Re:How to login to an MsSQL Server though a BDE TDatabase


I'm sorry I was doing somthing wrong. I solve this.
Quote
fabrizio wrote:
> Hi there,

> I'm trying to login programatically to an SQL I Have a TDatabase Object
> which uses the AliasName property to
> get the conection values and then I sustitute the "USER NAME" and
> "PASSWORD" Values with the next code:

>   Ix = dbIsxml->Params->IndexOfName("USER NAME");
>   if ( Ix >= 0 )
>      {
>        sData = frmMain->getUserName();
>        dbIsxml->Params->Values[ Ix ] = sData;
>        sData = dbIsxml->Params->Values[ Ix ];

>        Ix    = dbIsxml->Params->IndexOfName("PASSWORD");
>        sData = frmMain->getUserName();
>        dbIsxml->Params->Values[ Ix ] = sData;
>        sData = dbIsxml->Params->Values[ Ix ];
>      }
>   else
>      {
>        Ix = dbIsxml->Params->Add("USER NAME");
>        sData = frmMain->getUserName();
>        dbIsxml->Params->Values[ Ix ] = sData;
>        sData = dbIsxml->Params->Values[ Ix ];
>      }

>   Ix = dbIsxml->Params->IndexOfName("PASSWORD");
>   if ( Ix >= 0 )
>      {
>        sData = frmMain->getUserName();
>        dbIsxml->Params->Values[ Ix ] = sData;
>        sData = dbIsxml->Params->Values[ Ix ];
>      }
>   else
>      {
>        Ix = dbIsxml->Params->Add("PASSWORD");
>        sData = frmMain->getUserName();
>        dbIsxml->Params->Values[ Ix ] = sData;
>        sData = dbIsxml->Params->Values[ Ix ];
>      }

> But it alway return an "Invalid user or password" error If I put
> staticlly the parameters editing the TDatabase Properties it works.

> Does anyone have any idea ?

Re:How to login to an MsSQL Server though a BDE TDatabase


Have you checked if nt-authorisation is required in the odbc connection, it
should be sql-server authentication? You can also consider using ado instead
of bde, works much better also with authenticating. (just a connection
string)

Quote
"fabrizio" <fabri...@interalia.net> wrote in message

news:3C48C09C.2469ADF@interalia.net...
Quote
> I'm sorry I was doing somthing wrong. I solve this.

> fabrizio wrote:

> > Hi there,

> > I'm trying to login programatically to an SQL I Have a TDatabase Object
> > which uses the AliasName property to
> > get the conection values and then I sustitute the "USER NAME" and
> > "PASSWORD" Values with the next code:

> >   Ix = dbIsxml->Params->IndexOfName("USER NAME");
> >   if ( Ix >= 0 )
> >      {
> >        sData = frmMain->getUserName();
> >        dbIsxml->Params->Values[ Ix ] = sData;
> >        sData = dbIsxml->Params->Values[ Ix ];

> >        Ix    = dbIsxml->Params->IndexOfName("PASSWORD");
> >        sData = frmMain->getUserName();
> >        dbIsxml->Params->Values[ Ix ] = sData;
> >        sData = dbIsxml->Params->Values[ Ix ];
> >      }
> >   else
> >      {
> >        Ix = dbIsxml->Params->Add("USER NAME");
> >        sData = frmMain->getUserName();
> >        dbIsxml->Params->Values[ Ix ] = sData;
> >        sData = dbIsxml->Params->Values[ Ix ];
> >      }

> >   Ix = dbIsxml->Params->IndexOfName("PASSWORD");
> >   if ( Ix >= 0 )
> >      {
> >        sData = frmMain->getUserName();
> >        dbIsxml->Params->Values[ Ix ] = sData;
> >        sData = dbIsxml->Params->Values[ Ix ];
> >      }
> >   else
> >      {
> >        Ix = dbIsxml->Params->Add("PASSWORD");
> >        sData = frmMain->getUserName();
> >        dbIsxml->Params->Values[ Ix ] = sData;
> >        sData = dbIsxml->Params->Values[ Ix ];
> >      }

> > But it alway return an "Invalid user or password" error If I put
> > staticlly the parameters editing the TDatabase Properties it works.

> > Does anyone have any idea ?

Other Threads