Solved

Connect to the sql server

Posted on 2000-02-23
4
171 Views
Last Modified: 2010-04-04
I wrote a simple client program which connect to sql server. In the program, i have a data module which has a "database" component. During design time, I supply the parameters : "username = sa
              password = sa" which should provide the right login name & password. Somehow, everytime, the program running, it has error message;
  "invalid username & password, login failed". I changed the "database" property allow the "login prompt" as "true", that way, the program running fine with the sql login box come up every time. ( and I provide sam e user name and password to it). I don't understand why this could happen?
Is there any way I can succeed to connect sql database without the login prompt coming up?

Thanks!
 
0
Comment
Question by:llucy88
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
ZifNab earned 60 total points
ID: 2551453
you can try this :

 procedure TForm1.Database1Login(Database: TDatabase;
         LoginParams: TStrings);
   {The Event OnLogin from TDataBase}
    begin
      LoginParams.Values['USER NAME'] := 'YourUserName';
      LoginParams.Values['PASSWORD'] := 'YourPassWord';
    end;

I think is has to be user name= ... and password= ...

Zif.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 2551467
sorry i meant:  

in design-mode

username=username and password=password (perhaps the spaces are the problem)

the code above is for run-time.

Zif.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2551668
hi llucy, zif,

sometimes its nice to see fragments from my paqs ;-)
here the whole answer for the direction that zif meant

--- begin paste


                   use the TDatabase Component,
                   give on the Property DataBaseName a name
                   give on the Property AliasName the Name of the Alias you want to use

                   on the TTable(s) and/or TQuery(s) Components you use the Property DataBaseName should
                   have the same entry as TDataBase.DataBaseName.

                   Now you can use Following code :

                   procedure TForm1.Database1Login(Database: TDatabase;
                     LoginParams: TStrings);
                   {The Event OnLogin from TDataBase}
                   begin
                     LoginParams.Values['USER NAME'] := 'YourUserName';
                     LoginParams.Values['PASSWORD'] := 'YourPassWord';
                   end;

                   procedure TForm1.BitBtn1Click(Sender: TObject);
                   begin
                     {Connect Now}
                     database1.connected := true;
                     table1.open;
                   end;

--- end paste

good luck on the try

meikl
0
 

Author Comment

by:llucy88
ID: 2551683
On design time, the space was the problem. It should as "USER NAME" in
stead of " USERNAME".

Thanks!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question