Click here to Skip to main content
15,906,285 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi all,
I have created a winform application with visual studio 2010 and a setup project for it.my application works with sql express so i have added sql express 2008 to prerequisits of the setup.
In addition i have used the following connection string to connect to my database :

Data Source=.\SQLEXPRESS; AttachDBFileName=|DataDirectory|\MyDBName.mdf; Integrated security=True;

my application and its setup project build successfully but when i have install and run it (even by Run as Administrator) i have receive an error like this :

cannot open a user default database.login failed.
login failed for this user.


what is my mistake??
Posted

1 solution

Pass your credential in connection string.
and use Persist Security Info instaed of Integrated Security
C#
Data Source=.\SQLEXPRESS; AttachDBFileName=|DataDirectory|\MyDBName.mdf;
Persist Security Info=True;User ID=youruserid;Password=password"


check more connectionstrings
http://www.connectionstrings.com/sql-server-2008[^]
 
Share this answer
 
v2
Comments
M_Mogharrabi 1-May-12 1:02am    
Thanks but i do not have any user Id and Password..??
uspatel 1-May-12 1:06am    
try
Trusted_Connection=Yes;
as
Data Source=.\SQLEXPRESS; AttachDBFileName=|DataDirectory|\MyDBName.mdf;
Trusted_Connection=Yes;

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