Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I developed winform project VS c# 2010 with SQL server 2008. My side project working
properly, My client system getting error message showing bellow.

Database 'C:\PROGRAM FILES\DEFAULT COMPANY NAME\TTCS SETUP\TTCSSQL.MDF' cannot be
upgraded because it is read-only, has read-only files or the user does not have
permissions to modify some of the files. Make the database or files writable,
and rerun recovery.
An attempt to attach an auto-named database for the C:\Program Files\Default
Company Name\TTCS Setup\TTCSSQL.mdf failed. A database with the same
name exists, or specified file cannot be opened, or it is located on UNC share.


Below connection I am using my project.

<add name="TTCS" connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename="|DataDirectory|\TTCSSQL.mdf";Integrated
Security=True;Connect Timeout=30;User Instance=False"
providerName="System.Data.SqlClient" />

I create setup file included TTCSSQL.mdf file. When I install client
system c drive automatically created TTCSSQL.mdf but did not work.
Bellow code is login form code.

public TTCS()
{
InitializeComponent();
}
SqlConnection cs = new
SqlConnection(ConfigurationManager.ConnectionStrings["TTCS"].ConnectionString);

What I have tried:

I developed winform project VS c# 2010 with SQL server 2008. My side project working


 <add name="TTCS" connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename="|DataDirectory|\TTCSSQL.mdf";Integrated
Security=True;Connect Timeout=30;User Instance=False"
providerName="System.Data.SqlClient" />

I create setup file included TTCSSQL.mdf file. When I install client
system c drive automatically created TTCSSQL.mdf but did not work.
Bellow code is login form code.

public TTCS()
        {
            InitializeComponent();
        }
        SqlConnection cs = new
SqlConnection(ConfigurationManager.ConnectionStrings["TTCS"].ConnectionString);
Posted
Comments
Richard MacCutchan 11-Jan-17 4:50am    
You should do what the error message is telling you.
Venkatachalam Vijayakumar 11-Jan-17 5:25am    
Database 'C:\PROGRAM FILES\DEFAULT COMPANY NAME\TTCS SETUP\TTCSSQL.MDF' cannot be
upgraded because it is read-only, has read-only files or the user does not have
permissions to modify some of the files. Make the database or files writable,
and rerun recovery.
An attempt to attach an auto-named database for the C:\Program Files\Default
Company Name\TTCS Setup\TTCSSQL.mdf failed. A database with the same
name exists, or specified file cannot be opened, or it is located on UNC share.
[no name] 11-Jan-17 8:14am    
And? The error message tells you EXACTLY what the problem is.
Thomas Nielsen - getCore 11-Jan-17 8:01am    
If the side project runs and work sok with the databse already on your sqlexpress, means it's there. Then just use a regular connectionstring in your project and connect to the instance instead of that attach method :)

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