I am the owner of SDAC.
Is there any method of SDAC to check if a specified Database exists on the SQL server?
The purpose of doing this is to create the Database automatically if it doesn't exist on the server
check if the database exists
You can use something like following:
Code: Select all
MSQuery1.SQL.Text := 'SET :p1 = DB_ID (N''MyDatabase'')';
MSQuery1.ParamByName('p1').ParamType := ptInputOutput;
MSQuery1.ParamByName('p1').DataType := ftSmallInt;
MSQuery1.Execute;
if MSQuery1.ParamByName('p1').IsNull then begin
// Database doesn't exist.
end
else
// Database exists.