Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, ADODB;

type
TForm1 = class(TForm)
ADOConnection1: TADOConnection;
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
s : string;
begin
if adoconnection1.connected then
begin
adoconnection1.Connected:=false;
end else
begin
s := adoconnection1.ConnectionString;
s := adodb.PromptDataSource(self.Handle, s);
adoconnection1.ConnectionString := s;
try
adoconnection1.connected:=true;
except
end;
end;
Edit1.text := s;
end;
end.

What I have tried:

I have this code for access database i want the same code for sql server thanks
Posted
Updated 28-Jun-17 12:11pm

1 solution

ADO can talk to SQL too - it's just a change to the connection string

SQL Server connection strings - ConnectionStrings.com[^]
 
Share this answer
 
Comments
rezki_z 28-Jun-17 22:44pm    
I hnow but when i add sql provider give me error
barneyman 29-Jun-17 0:57am    
ok
rezki_z 29-Jun-17 3:00am    
So i hope you can help me with source code working and thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900