The situation is this, I create the following code from a C # application
CreateDB_SQL_command = "CREATE DATABASE " + "ExpData" + " ON PRIMARY " + "(NAME = Exp_Data_" + @DbName + ", " + @"FILENAME = '" + @DbFileName + "', " + "SIZE = 100MB, MAXSIZE = 10GB, FILEGROWTH = 10%) " + "LOG ON (NAME = " + @DbLogName + ", " + @"FILENAME = '" + @DbLogFileName + "', " + "SIZE = 100MB, " + "MAXSIZE = 5GB, " + "FILEGROWTH = 15%)"; SqlCommand myCommand = new SqlCommand(CreateDB_SQL_command, myConn); try { myConn.Open(); myCommand.ExecuteNonQuery(); } The base is created, everything is fine, from ManagmenStudio is perfectly controlled, but when you try to open it
switch (open_db_file.ShowDialog()) { case System.Windows.Forms.DialogResult.OK: if (open_db_file.FileNames.Count() > 1) { MessageBox.Show("необходимо выбрать только 1 файл", "ошибка"); return; } FilePath = open_db_file.FileName; break; case System.Windows.Forms.DialogResult.Cancel: return; } str_build = new SqlConnectionStringBuilder(); str_build.DataSource = ".\\SQLEXPRESS"; str_build.IntegratedSecurity = true; str_build.InitialCatalog = FilePath; str_build.MultipleActiveResultSets = true; using (ExpDataContext _db = new ExpDataContext(str_build.ToString())) { //....... } When I select a file in OpenFileDialog I get a MessageBox which says that I do not have permission to access this file. The problem is treated if the hands of this file register the access rights from the current windows user, through the explorer. Actually the question is, is it possible in some way to configure SQL Server or so modify the database creation script so that the current user, or at least everyone had the right to access the .mdf file? I read the manual from msdn, but did not find the answer there.