6 Replies - 980 Views - Last Post: 03 April 2013 - 09:21 AM Rate Topic: -----

#1 ray1234  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 148
  • Joined: 07-September 12

Connection string error?

Posted 03 April 2013 - 04:49 AM

I'm trying to connect to my database, but I'm having the following error,

Failed to generate a user instance of SQL server due to a failure in starting the process for the user instance.

I've been trying to log onto my database for 3 days, but keep getting an error after another the above being the latest.

I think the error could be within my connection string in my app config file:
the server is local, login in using windows authentification, it takes in a user name ray-pc-ray with no password. I'm connecting with entity framework meta data files, ssdl, csdl etc.

 <add name="videoRentalEntities1" connectionString="metadata=res://*/VideoRentalModel.csdl|res://*/VideoRentalModel.ssdl|res://*/VideoRentalModel.msl;provider=System.Data.SqlClient;provider connection string='Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\ray\Desktop\mini projects\NewVideoRental\Data_Access_Layer\videoRental.mdf; 
      Integrated Security = true; connect timeout=30;user instance=false;multipleactiveresultsets=True;App=EntityFramework'" providerName="System.Data.EntityClient" />



if this is ok then, I just followed this post click here, but Microsoft sql server data folder doesn't exist in my file system.

any ides on dealing this problem.

??

This post has been edited by modi123_1: 03 April 2013 - 05:40 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Connection string error?

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5625
  • View blog
  • Posts: 12,061
  • Joined: 02-June 10

Re: Connection string error?

Posted 03 April 2013 - 06:24 AM

"With no password"
As a rule I avoid this everywhere: Windows login, sites, applications. Its hard for a system to store 'nothing' or 'null'. Usually null is used to indicate that no entry has been made. I'd recommend you create a password to see if that helps. OR at the very least it will be one more test to eliminate a possible cause.
Was This Post Helpful? 0
  • +
  • -

#3 ray1234  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 148
  • Joined: 07-September 12

Re: Connection string error?

Posted 03 April 2013 - 07:20 AM

thanks for the reply.

I managed to solve this problem now.

I changed my connection string, to this

<connectionStrings>
    <add name="videoRentalEntities1" connectionString="metadata=res://*/VideoRentalModel.csdl|res://*/VideoRentalModel.ssdl|res://*/VideoRentalModel.msl;provider=System.Data.SqlClient;provider connection string='Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\ray\Desktop\mini projects\NewVideoRental\Data_Access_Layer\videoRental.mdf; 
      Integrated Security = true; User Instance = true; connect timeout=30;multipleactiveresultsets=True;App=EntityFramework'" providerName="System.Data.EntityClient" />
  </connectionStrings>



I then typed this query in sql server management studio to enable user instances

exec sp_configure 'user instances enabled', 1. 
 Go
 Reconfigure



then type reconfigure in the query window

Reconfigure



then delete sqlexpress folder in the following directory

C:\Documents and Settings\YOUR_USERNAME\Local Settings\Application Data\Microsoft\Microsoft SQL Server Data\SQLEXPRESS.

because I am using windows 7 I use following dir: C:\Users\{your name]\AppData\Local\Microsoft\Microsoft SQL Server Data\SQLEXPRESS

p.s if you can't find appdata folder you have to enable hidden folders. controlsetting->folder options -> View tab -> select show hidden files, folders and drives. click ok. now app data folder should be visible.

once directory is deleted, restart sqlexpress instance from sql config management studio tool. rebuild your project.

then bingo problem solved

ray

This post has been edited by ray1234: 03 April 2013 - 07:27 AM

Was This Post Helpful? 0
  • +
  • -

#4 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5625
  • View blog
  • Posts: 12,061
  • Joined: 02-June 10

Re: Connection string error?

Posted 03 April 2013 - 07:37 AM

Congrats on resolving the issue!

Quote

C:\Users\ray\Desktop\mini projects\NewVideoRental\Data_Access_Layer\videoRental.mdf


I will point out that this won't work anywhere but your machine under your log-in. If this is just an R&D project to learn this then fine. But I would suggest you get in the habit of building dynamic addresses. Take the time to make a common code or shared code namespace for all your projects that covers things like finding the current user's documents directory.
http://msdn.microsof...cialfolder.aspx
Was This Post Helpful? 1
  • +
  • -

#5 Curtis Rutland  Icon User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4559
  • View blog
  • Posts: 7,971
  • Joined: 08-June 10

Re: Connection string error?

Posted 03 April 2013 - 08:54 AM

Quote

login in using windows authentification, it takes in a user name ray-pc-ray with no password


Just for anyone else reading this, the whole point of integrated security is so that you don't have to put a password in your connection string. You can still have a password on your account, it'll just run in the context of whatever user is running the application. In the case of a web service or web site, the App Pool identity will be the account it runs under, unless you specifically impersonate someone else.
Was This Post Helpful? 2
  • +
  • -

#6 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5625
  • View blog
  • Posts: 12,061
  • Joined: 02-June 10

Re: Connection string error?

Posted 03 April 2013 - 09:10 AM

Quote

login in using windows authentification, it takes in a user name ray-pc-ray with no password


Maybe I'm interpreting this wrong but... To me the OP is saying his Windows account has no password. Which I have experienced numerous problems with. Lots of other technologies freak out when the Windows User Account has no password. You can't have automatic log-in to Windows, remote debugging doesn't like the lack of a password and so on.
Was This Post Helpful? 1
  • +
  • -

#7 Curtis Rutland  Icon User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4559
  • View blog
  • Posts: 7,971
  • Joined: 08-June 10

Re: Connection string error?

Posted 03 April 2013 - 09:21 AM

No, I think you read it correctly. I just misread it at first, and was clarifying it for anyone with the same misinterpretation.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1