Click here to Skip to main content
14,426,997 members
Rate this:
Please Sign up or sign in to 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 13:11pm

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

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

SQL Server connection strings - ConnectionStrings.com[^]
   
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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100