Board index » delphi » Getting table names without prompt from user name and password

Getting table names without prompt from user name and password

How could I proceed to get the table names from a SQL database without
receiving the User Name and Password dialog box ? That is, I would like to
pass that information to the database without prompt to the user.

Thanks in advance,

Mauro Assis

 

Re:Getting table names without prompt from user name and password


  This is a pretty common question.

  Use a TDatabase - set the paswordPrompt to False, and open a connection.
  Then you can use your tquery or whatever without the password prompt
coming up.

  --Jeremy Prowse

Quote
"Mauro Assis" <ath...@athenasoft.com.br> wrote in message

news:8e78d5$2ak10@bornews.borland.com...
Quote
> How could I proceed to get the table names from a SQL database without
> receiving the User Name and Password dialog box ? That is, I would like to
> pass that information to the database without prompt to the user.

> Thanks in advance,

> Mauro Assis

Re:Getting table names without prompt from user name and password


Add a TDatabase component to your project.  Setup the username and password
in the param property.  Set the LoginPrompt to false.  Then connect your
datasets to the database component (dataset.databasename =
database.databasename).

Ping

Quote
Mauro Assis <ath...@athenasoft.com.br> wrote in message

news:8e78d5$2ak10@bornews.borland.com...
Quote
> How could I proceed to get the table names from a SQL database without
> receiving the User Name and Password dialog box ? That is, I would like to
> pass that information to the database without prompt to the user.

> Thanks in advance,

> Mauro Assis

Re:Getting table names without prompt from user name and password


Use a database object turning off password. The connect the ttable or tquery
to the database object
Quote
Mauro Assis wrote in message <8e78d5$2a...@bornews.borland.com>...
>How could I proceed to get the table names from a SQL database without
>receiving the User Name and Password dialog box ? That is, I would like to
>pass that information to the database without prompt to the user.

>Thanks in advance,

>Mauro Assis

Re:Getting table names without prompt from user name and password


Thank you both, Ping and Jeremy.

However, I think you didn't understand my question (because my very poor
English habilities, I think...).

I need to get the 'table names' of a database. I'm using the
TSession.GetTableNames method,  and when I call the method the application
prompts the user about the User Name and Password. How could I avoid this ?
That is, how can I "tell" the TSession the UN and PWD before call
GetTableNames method ?

Thanks again,

Mauro

Quote
Jeremy Prowse <jpro...@clearpicture.com> wrote in message

news:39073250@dnews...
Quote

>   This is a pretty common question.

>   Use a TDatabase - set the paswordPrompt to False, and open a connection.
>   Then you can use your tquery or whatever without the password prompt
> coming up.

>   --Jeremy Prowse

Re:Getting table names without prompt from user name and password


Same.  Add a database component to your application.  Setup the param
property and then set loginprompt to false.

The following buttonclick event shows all the tables in the database.  Note
that db1 is the databasename of database1.

procedure TForm1.Button1Click(Sender: TObject);
var
  slTables: TStringList;
begin
  Database1.Connected := True;
  slTables := TStringList.Create;
  try
    Database1.Session.GetTableNames('db1', '', False, False, slTables);
    showmessage(sltables.text);
  finally
    slTables.Free;
  end;
end;

Ping

Re:Getting table names without prompt from user name and password


  Yes...

 Or you can leave the TDatabase as garnishes within the function:

procedure blah.blah;
var
  db : TDatabase;
begin
  db := TDatabase.Create(NIL);
  db.DatabaseName := 'Funky_Chicken_BDE_Alias';
  db.LoginPrompt := False;
  db.Open;

  (Your TSession code)

  db.Close;
  db.Free;
end;

  --Jeremy Prowse

Quote
"Ping Kam" <p...@quikcard.com> wrote in message

news:8eahng$2vr9@bornews.borland.com...
Quote
> Same.  Add a database component to your application.  Setup the param
> property and then set loginprompt to false.

> The following buttonclick event shows all the tables in the database.
Note
> that db1 is the databasename of database1.

> procedure TForm1.Button1Click(Sender: TObject);
> var
>   slTables: TStringList;
> begin
>   Database1.Connected := True;
>   slTables := TStringList.Create;
>   try
>     Database1.Session.GetTableNames('db1', '', False, False, slTables);
>     showmessage(sltables.text);
>   finally
>     slTables.Free;
>   end;
> end;

> Ping

Other Threads