Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Simple question on Database Connection

Posted on 2003-03-04
5
Medium Priority
?
136 Views
Last Modified: 2013-11-23
I am using MS SQL database with a database named mercy.
I am able to connect to the database successfully but everytime i run the program, it will always prompt me for the user name and password to connect to the database. Is there a way to code this into the program itself? Can someone show me the code? I am using Delphi 5.0
0
Comment
Question by:sunslinger
  • 2
  • 2
5 Comments
 
LVL 21

Expert Comment

by:ziolko
ID: 8069977
one of possible solutions with ADO:
ADOConnection.LoginPrompt:=False;
ADOCOnnection.ConnectionString:='Provider=SQLOLEDB.1;Persist Security Info=False;User ID=login;Password=yourpwd;Initial Catalog=mercy;Data Source={yourSQLServername}';


ziolko.
0
 

Author Comment

by:sunslinger
ID: 8070008
I'm not using ADOConnection... i am using the buttons under the data access tab
0
 
LVL 22

Accepted Solution

by:
Mohammed Nasman earned 80 total points
ID: 8070071
Hello

  Are you using ADO or BDE? here are two examples for both, but I have oracle, but it's easy to change them to Ms Sql server:

using ADO you need to add AdoConnection
  try      
  ADOConnection1.ConnectionString := 'Provider=MSDAORA.1;Data Source=pro8500;';
    AdoConnection1.LoginPrompt := False;
    AdoConnection1.Open('scott','tiger');
    Form2.Show;
  except
    ShowMessage('Wrong Password');
  end;

and for BDE you need Database Component
  try
   with Database1 do begin
     Params.Values['USER NAME'] := 'Scott';
     Params.Values['PASSWORD'] := 'tiger';
     LoginPrompt := False;
     Connected := True;
  except
    ShowMessage('Wrong Password');
  end;

and don't forget to attach your Tables and Query to the Database or AdoConnection components


Best regards
Mohammed Nasman
0
 

Author Comment

by:sunslinger
ID: 8070154
Wow! Thanks so much for your prompt reply!!
Thank you so much mnasman!

I am using BDE and yes I was missing the Database component. (I'm a newbie)
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 8070162
You are welcome :-)
0

Featured Post

Technology Partners: 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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month12 days, 12 hours left to enroll

578 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