I have an MDF SQL database file, I want to connect to this file using ADOConnection and SQL Client 11.0 as a provider
ADOConnection successfully connects, but no table!
ADOConnection.GetTableNames() returns ""
My code looks 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 a database with SQL Server Managment Studio, tables exist
Edit :
I removed the "Initial File Name" and now ADOConnection was unable to connect:
An attempt to attach a database with an auto-name for the file "G: \ Projects \ Delphi \ Pasargad Insurance \ DB \ Main2.mdf" failed. A database with the same name exists or the specified file cannot be opened or is located on the UNC shared folder
LocalDB off, SQLServer Managment Studio , .