Click here to Skip to main content
15,307,535 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Sir ,
i have a problem with my setup. When i work in Xp its works correctly but it's not working with Windows 7....
The connection string is
C#
SqlConnection sqlcon = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\crm.mdf;Integrated Security=True;User Instance=True");


Thanks....
Posted
Updated 1-Jan-12 22:25pm
v2
Comments
Wendelius 2-Jan-12 4:25am
   
What error are you getting?
manish the error 2-Jan-12 4:44am
   
Thanks for reply sir,
this error is generated in windows 7
*****************
System.Data.SqlClient.SqlException: Could not open new database 'C:\PROGRAM FILES\INNOMARK\CRM ELECTRONICS\CRM.MDF'. CREATE DATABASE is aborted.
An attempt to attach an auto-named database for file C:\Program Files\Innomark\CRM Electronics\crm.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
File activation failure. The physical file name "C:\Program Files\Innomark\CRM Electronics\crm_log.ldf" may be incorrect.
The log cannot be rebuilt when the primary file is read-only.
Jan Steyn 2-Jan-12 4:54am
   
Does the user account under which you are executing the program have full control to the database file?
manish the error 2-Jan-12 5:35am
   
yes sir its have full control to the database file.

1 solution

Few thing s to check:
- does the mdf file actually exist in that location
- do you (actually the SQL Server service) have necessary privileges. In windows 7 program files directory is more protected so also you can try placing the database file somewhere else and see if it works. (Something like c:\database\...).
   
Comments
manish the error 2-Jan-12 5:51am
   
Thanks for reply sir,
but i have checked all these solutions...
these are not working ...
please give me another solutions

and sir i am giving database, and sqlserver setup both with c# setup , it's working with xp or not working with windows 7.....

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