Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Connect to the sql server

Posted on 2000-02-23
Medium Priority
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?

Question by:llucy88
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

Accepted Solution

ZifNab earned 240 total points
ID: 2551453
you can try this :

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

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


Expert Comment

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.

LVL 27

Expert Comment

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}
                     LoginParams.Values['USER NAME'] := 'YourUserName';
                     LoginParams.Values['PASSWORD'] := 'YourPassWord';

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

--- end paste

good luck on the try


Author Comment

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


Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

618 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