'How to validate mssql server credentials
In my project, I use Inno to run a .sql script to create a database. I use a custom page to write SQL Server instance name user and password to run the script. I would like to add the validation of the entered credentials. What's the best way?
Update: I'm testing this approach
function ConnDBAndExecSql(istanza,utente,password:string):Boolean;
var
ADOConnection: Variant;
begin
Result := False;
try
// create the ADO connection object
ADOConnection := CreateOleObject('ADODB.Connection');
// build a connection string; for more information, search for ADO
// connection string on the Internet
ADOConnection.ConnectionString :=
'Provider=SQLOLEDB.1;' + // provider
'Data Source='+ istanza +';' + // server name
'Persist Security Info=True;' +
'User Id=' + utente + ';' + // user name
'Password='+ password + '; '; // password
// open the connection by the assigned ConnectionString
ADOConnection.Open;
Result := True;
//ADOConnection.Connected:=True;
except
Result:= False;
end;
end;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|