Jump to content
Sign in to follow this  
kazzoo

Innlogging på database

Recommended Posts

Jeg bruker denne prosedyren i database programmet mitt:

procedure TForm1.btnAutoTilkoblingClick(Sender: TObject);

var

dbList: TStringList;

TableList: TStringList;

i: Integer;

dbName: string;

sTemp: string;

begin

//select computername

dbList := TStringList.Create;

Session1.SessionName := ePCNavn.Text;

Session1.Active := True;

Session1.GetAliasNames(dbList);

lbDatabaser.Items.AddStrings(dbList);

//btnKobleTil.Enabled := false;

//btnKobleFra.Enabled := true;

lOppkobling.Caption := Session1.SessionName;

dbList.Free;

 

//select database

TableList := TStringList.Create;

dbList := TStringList.Create;

lbTabellListe.Clear;

//For å få tabellnavn trengs DNSens DBNnavn.

Session1.GetAliasParams(eDBName.Text,dbList);

for i := 0 to dbList.Count - 1 do

begin

sTemp := copy(dbList,1,23);

if (lowercase(copy(sTemp,1,3)) = 'db=') then

begin

dbName := copy(sTemp,4,20);

Table1.DatabaseName := trim(dbName);

Query1.DatabaseName := eDBName.Text;

end

else if (lowercase(copy(sTemp,1,9)) = 'odbc dsn=') then

begin

dbName := copy(sTemp,10,30);

Table1.DatabaseName := trim(dbName);

Query1.DatabaseName := eDBName.Text;

end;

end;

Session1.GetTableNames(dbName,'*',True,True,TableList);

lbTabellListe.Items.AddStrings(TableList);

dbList.Free;

TableList.Free;

 

//select tabell

//select seksjonen

Table1.Active := False;

Table1.DatabaseName := eDBName.Text;

Table1.TableName := eTabellName.Text;

Table1.Active := True;

 

//Query seksjonen

Query1.Active := False;

Query1.SQL.Clear;

Query1.SQL.Add('Select * from ' + eTabellName.Text);

Query1.Active := True;

end;

 

Problemet er når linjene Session1.GetAliasParams(eDBName.Text,dbList); og Table1.Active := True; eksikveres så får jeg en pop-up med Database Login, her skal jeg skrive inn brukernavn og passord. Disse er blanke for min del og har derfor ikke bruk for denne pop-upen. Noen som vet hvordan en kan bli kvitt noe sånt?

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...