How can i do this:

have a edit.text for users username
have a edit2.text for users password

then connects to SQL database on ""
database name: mydatabase_db
logs in with name and password.

If OK then form2.show;
if not, label1.caption:="not logged in";

please im desperate now...

if i need components please proive link and code how to do it please.

This is all.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

For one thing, your DataModule needs to not automatically connect to the database.
For another, you need to have the LogOn form called as the first thing that happens in the OnShow event of the main form.  Then the LogOn form needs to return a true/false indication as to whether it successfully logged on.  Based on that true/false result, you can either go ahead and do whatever the main form does or you can exit the application.
966Author Commented:
yeah, i know that already. Thanks for commenting anyway.
You didn't provide us some information
What is type of your database?
Have experience about SQL database in Delphi?
As quick response check this topic
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Hi 966.

Its pretty simple.
There are may DAC components out there.
(Direct Access components)

The one that i trully love is AnyDAC. You can contact your server NO MATTER what kind
of database you are running up there.
(Or you can try ADO, in your Delphi)

You can download it from here:

If you don't like it then you can google for DAC components for Delphi.
All the components you will try will work with the way i'll describe.

On your form after you install you DAC component drop :

1) A connection (in case of AnyDAC its named: ADConnection)
2) A Query (in case of AnyDAC its named: ADQuery)
3) A WaitCursor (this is needed for AnyDAC only its named: ADGUIxWaitCursor)
4) Depends on your database on your server if its MySQL then drop a ADPhysMySQLDriverLink ...
Else Oracle: ADPhysOracleDriverLink1 etc...

Its all very simple after that.
With Button1 click event do :

 AdConnection1.Params.Values['Password']:= Edit1.Text;
AdConnection1.Params.Values['Username']:= ...Edit2.Text;
AdConnection1.Params.Values['Database']:= The name of your database here.

Hope this helps.
If you have any question don't hesitate.

966Author Commented:
Thanyou very much CodedK:, ill chec it out now.
966Author Commented:
ive some DAC components, but they dont have much with them. Can you lin me to some delphi 7 AnyMAC components, ?

also do they cost, n how much?
966Author Commented:
Not MAC sorry lol, DAC.

I have MyDac but i need AnyDAC
So, what part of the problem are you having trouble with?  
  • Connecting to the database at all?
  • Specifying the UNC for the IP address?
  • Figuring out which components to use?
  • What?
966Author Commented:
n/m i thin you posted above, sorry i didnt chec that link untill now
966Author Commented:
Hi,mate. Got them, AnyDAC.

AdConnection1.Params.Values['Password']:= Edit1.Text;
AdConnection1.Params.Values['Username']:= ...Edit2.Text;
AdConnection1.Params.Values['Database']:= The name of your database here.

can you show me where i put database name, im not sure how to set it out
966Author Commented:
AdConnection1.Params.Values['Password']:= Edit1.Text;
AdConnection1.Params.Values['Username']:= Edit2.Text;
AdConnection1.Params.Values['Database']:= 'servicefg_dlik;


also, how would i know its ok..

can form2.show if its connected fine?

andif its wrong password and username label1.caption changes to error ?

Hi 966 sorry for not answering earlier.
Its 3 in the morning here, but i've made an example application for you.

Well, do this :

procedure TForm4.Button1Click(Sender: TObject);
  Flag: Boolean;
  ADConnection1.Params.Values['User_Name']:= Edit1.Text;
  ADConnection1.Params.Values['Password']:= Edit2.Text;
      ShowMessage('Unauthorized access');

  if Flag then
    ShowMessage('ready to load form2 now...');


1) Double click ADConnection1
Inside the window write the name of your database
Check the image i uploaded.

2) IF you use MySQL drop this dll inside your folder (i uploaded as bmp. rename it to dll).

3) IF YOU use MySQL then click ADPhysMySQLDriverLink1 and from the Properties the "Vendor Lib" add the path to the dll i uploaded.

Simple as that (check the images, they will help)

If you stuck in something tell me.

I uploaded some images too , just for visual aid.

Hope this will help.
966Author Commented:
THANKS for your amazing description, im just half way through.

2 things friend.

1) when i select SQL from list it gives an error of the DLL, but i am unable to get it from that link, it wont let me right click save AS, or even click it. Not AV related as its OFF.

966Author Commented:
its ok mate, i got it from asite. doing project now will report back
966Author Commented:

not found when it tries to give an error. ill keep trying
966Author Commented:
also, i put details in exact, and even with correctpass and name it still says its wrong?

any idears mate, thanyou so much by the way
966Author Commented:
database_name  << again

then inside of that we have:

  ID  username  password  
  1      test 2cc5143f1dd3c0f9a00a146d37bffff7e51aff
  2      lu5 343d9040a671cfffffd45832ee5381860e2996
  3      Ais 2cc5143f13c0f9a00a1fffdd46d37b7e51aff

so when say Ais logs in he can with his correct deatils.
966Author Commented:
sorry for all the posts , but i think it must have something to do with that .PAS files, as it is not making the connection active? maybe.
The hours that i work ... really killing me!
Well, you don't have nothing wrong mate.

When you specify ADPhysManager, you just say i want something to manage my connection because databases come in several flavors. Oracle, MySQL, SQL Server etc...

The manager that it cant find is the dll in the path (that currently is null)

I think like most people you have MySQL in your server. (not dedicated etc)

It just cant work without the LibMySQL if its not in a path specified as it should.
You are not doing something wrong.

By the way i just downloaded MySQL from my link, i don't know whats wrong.

Most Vista and 7 and some XP have already have libMySQL inside windows/system folder.

Anyway i uploaded it again here:

If you don't want to put my dll in your system you have to download an application that has libmysql along with it.
First result in google :

Mine is version 5.0.22 and it has 151 functions of MySQL inside. It came along with MySQL server.

Anyway just drop the dll wherever you get it to your folder where your application resides and then just click.

Check my image.

Hope this will clarify everything and work as it should.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
I will upload the application here for you so we don't have other errors.
You say you got the dll from another site. Then the error is strange. Maybe the dll file is to blame...
There is no error in version 2.015 of AnyDAC and it works for every version of Delphi.

I uploaded my application with sources.


Try it and tell me :)
Geert GOracle dbaCommented:
in all these posts, you haven't said what database you are trying to connect to
is it mysql ?
is it ms sqlserver ?
is it oracle ?
is it teradata ?

this is the basic question you need to answer first !

966Author Commented:
thanks again for the uploads and everything you have done. For me, even in your example, it still asks for the same file.

I reinstalled the trial last night, maybe that has something to do with it?

Ive followed each step close and everythingyou said is find, untill i come to compilem and it stops, gives me a browse path for the file. see attached image:

I even replaced the DLL file. haha, i have no idea mate. Im going to try it with delphi6 later today when i get in from work, then reinstall delphi7 incase something messed up or its conflicting with some of my million components haha.

Thankyou so much, your so helpful and thats what makes experts exhange a pleasure to get help from.

Oh by the way, i couldn't even get ur example to work, so itmust be a problem with the objects.

Ill try sys-restore tonight and then re-add the components..

Is there a patch because they seem expensive, and im only ever going to be logging in to mySql.

well, any user tat gets my client, if they are registerd to my site, they can login via the delphi app.
966Author Commented:

966Author Commented:
Geert, sorry it's MySQL mate.

If i can find another way to just, have my users login if they are registered, its perfect.

even if its free components the better.

Anyway would do.
966Author Commented:
Also, im running MySQL ona dedicated server. All i need is when someone types in username and password it checks to make sure they are registered. If they are, show message connected, if not, show not connected.
966Author Commented:
Just an update lads.

Tested on my main PC, and all is good. Works great. I want to thankyou for staying up late last night and helping me though this. FIRST CLASS MATE.
Amazing examples, great service and a credit to EE.

Now, its working perfect, few errors that ill sort out. However, i just checked and whoo!!! i can't afford to buy them!

Is there a patch or something,? Normally id buy them, but i only need it to connect and login. Or is there a way around it?

Glad i've helped.

I have the old version. (Better that the new one i think)
Anyway that version was free but when RemObject bought AnyDAC ...the old version was lost.

Just send me an email or post here your email to send you the old version.

My email is in my profile.
Thanks CPColin.

My mail is :

kenny22a   @   hotmail    .   com
966Author Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.