Click here to Skip to main content
15,900,589 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
private void OpenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Title = "database selection ";
            dlg.Filter = "database file (*.mdf)|*.mdf";
            dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            if (dlg.ShowDialog() == DialogResult.OK)
            {

 label1.Text = dlg.FileName;// Error here :: you don't have permission to open this file.


            }
        }


I create an appliction that create database programmatically, and I used a Dialog (OpenFileDialog class) in it;
for user to select the database which I mentioned above.
now when user want to open it(the *.mdf file that created ), it says <<you don't have permission to open this file.>>
my code for database creation is :

SQL
CREATE DATABASE TestDb  
 ON PRIMARY 
 (NAME = TestDb_Data,  FILENAME = 'C:\TestDb_Data.mdf',  SIZE = 2MB,FILEGROWTH =10%) 
 LOG ON
 (NAME =TestDb_Log,  FILENAME = 'C:\TestDb_Log.ldf',  SIZE = 1MB, FILEGROWTH =10%)


How should I change the code to get permission to the user ? or what I must better do ?gimme Solution...
Posted
Updated 12-Feb-10 0:34am
v3

1 solution

hi, see this KB
http://msdn.microsoft.com/en-us/library/ms178569.aspx[^]

:thumbsup:
گفتار نیک - پندار نیک - کردار نیک
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900