I have a SQL Database MDF file , I want to connect to that file with ADOConnection and SQL Client 11.0 as provider
ADOConnection connects successfully but there is no Table !
ADOConnection.GetTableNames()
returns ""
My code is like this :
ADOConnection1.ConnectionString := 'Provider=SQLNCLI11.1;Integrated Security=SSPI;Persist Security Info=False;User ID="";Data Source=(localdb)\v11.0;Initial File Name="";Server SPN="";'
+'AttachDbFileName="G:\Projects\Delphi\Pasargad Insurance\DB\Main.mdf";';
ADOConnection1.Connected := True;
ADOConnection1.GetTableNames(REdit.Lines);
When I connect to Database with SQL Server Managment Studio, tables are exists
Edit :
I removed "Initial File Name" and now the ADOConnection failed to connect :
An attempt to attach an auto-named database for file "G:\Projects\Delphi\Pasargad Insurance\DB\Main2.mdf" failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share
I switched tracing of LocalDB to off, copied my database file and deleted main database with SQLServer Managment Studio , and tried again to connect but the same error shown.