Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have develpoed application in winforms ,but when i open n client machine there are error occured..
" failed to generate a user instance of sql server due to failure in copying database files.the connection will be closed"
please give me solution for this .My connection string and code in app.config is following,
<?xml version="1.0"?>
<configuration>

<connectionstrings>
<add name="LN.Properties.Settings.dbLnConnectionString"
connectionString="Data Source=myPC;Initial Catalog=dbLn;User ID=sa;Password=sa123;User Instance=True"
providerName="System.Data.SqlClient" />



<system.windows.forms jitDebugging="true" />

<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>

But still this error occured,plz give me solution.i have face this problem since 15days

What I have tried:

<connectionstrings>
<add name="LN.Properties.Settings.dbLnConnectionString"
connectionString="Data Source=myPC;Attachfilename=DataDirectory|dbLn.mdf;User ID=sa;Password=sa123;User Instance=True"
providerName="System.Data.SqlClient" />
Posted
Updated 1-Dec-17 3:48am
Comments
ZurdoDev 1-Dec-17 9:34am    
You must have some code doing something weird somewhere.
Afzaal Ahmad Zeeshan 1-Dec-17 9:41am    
Also, does your engine/program have enough permissions to continue and execute the tasks you are talking about?
Richard Deeming 1-Dec-17 12:53pm    

1 solution

As I said when you posted this earlier:
Quote:
That string doesn't look right:
"Data Source=myPC" is unlikely - you'd normally have an SQL instance name on that as well.
"Provider=..." is not a keyword SQL Server supports.

Have a look here:
Simple SQL Connection String Creation[^]
It should help you (and your client) generate a working connection.

BTW: The sa user is not recommended - you should create a user with just enough permission to to the app's job. "sa" has full access to all DB's and can do anything to the system. Using that exposes your admin login to casual users, and puts things move at risk if there is an error in your code.
 
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