?
Solved

Simple question on Database Connection

Posted on 2003-03-04
5
Medium Priority
?
133 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
[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
  • 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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 this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

777 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