Nick
Nick

Reputation:

Connection String to Local DB file is not working

connectionString="AttachDbFilename=C:\Documents and Settings\nmartin\My Documents\PS_Upload\TimeTrack\src\TimeTracker\TimeTrack\App_Data\ASPNETDB.MDF;Integrated Security=True; User Instance=True"
     providerName="System.Data.SqlClient" />

This is the connection string that is provided to me from the Server Explorer for my local MDF file. I keep receiving the following error when attempting to run the application.

"Format of the initialization string does not conform to specification starting at index 25."

Anyone know what this is?

Thanks!

Upvotes: 4

Views: 7276

Answers (4)

Spikolynn
Spikolynn

Reputation: 4173

I'd say it is the spaces in file name. Try enclosing it in '' e.g.

connectionString="AttachDbFilename='C:\Documents and Settings\nmartin\My Documents\PS_Upload\TimeTrack\src\TimeTracker\TimeTrack\App_Data\ASPNETDB.MDF';Integrated Security=True; User Instance=True"

or copy it to c:\ for a test

Upvotes: 2

Nick
Nick

Reputation:

Thanks a lot everyone. My problem was actually with the connection string I was providing NHibernate configuration. It would appear that the local data file path should not be wrapped in 's or "s. Thanks for the replies.

Upvotes: 2

George Mastros
George Mastros

Reputation: 24498

Try replacing: Integrated Security=True

With: Trusted_Connection=Yes

Upvotes: 1

JB King
JB King

Reputation: 11910

Have you tried using escape characters on the backslashes?

connectionString="AttachDbFilename=C:\Documents and Settings\nmartin\My Documents\PS_Upload\TimeTrack\src\TimeTracker\TimeTrack\App_Data\ASPNETDB.MDF;Integrated Security=True; User Instance=True"
 providerName="System.Data.SqlClient" />

becomes

connectionString="AttachDbFilename=C:\\Documents and Settings\\nmartin\\My Documents\\PS_Upload\\TimeTrack\\src\\TimeTracker\\TimeTrack\\App_Data\\ASPNETDB.MDF;Integrated Security=True; User Instance=True"
 providerName="System.Data.SqlClient" />

Upvotes: 0

Related Questions