0

I am currently trying to create a program that is like a school management/timeInOut system.

I am using T-SQL as that is the default SQL version within visual studio as I thought this would be easier as they are fairly integrated. The problem I am having is the error: System.ArgumentException: 'Invalid value for key 'attachdbfilename'.'

With the connection string being:

string ConString = @"Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename =| DataDirectory |\GardenRegister.mdf; Integrated Security = True";

are there any ideas what is wrong and why it wont recognise the database, If possible I would also like someone to be in personal contact to help aid me in this as there are a few problems I have encountered.

WMTS
  • 53
  • 1
  • 1
  • 12
  • stupid question but is there GardenRegister.mdf in the app_data folder for the app? – Ken Tucker Jan 13 '18 at 17:03
  • XD, Yes there should be I did create it in the same location. Is there any chance i can send you the program via zip on google drive or something for you to have a look at? – WMTS Jan 13 '18 at 17:11
  • maybe the spaces between pipes and DataDirectory? see also [here](https://stackoverflow.com/q/12135081/1132334) – Cee McSharpface Jan 13 '18 at 17:12
  • Somehow that tiny edit worked, you my friend are a genius but now i receive another error further down: System.Data.SqlClient.SqlException: 'Invalid object name 'GardenRegister.Member'.' This is the only problem with making a local database EDIT: FIXED THE DATABSE OPENS NOW – WMTS Jan 13 '18 at 17:20

1 Answers1

0

ANSWERED DUE TO THE COMMENTS

"maybe the spaces between pipes and DataDirectory? see also here – dlatikay" Thank you

string ConString = @"Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename =|DataDirectory|\GardenRegister.mdf; Integrated Security = True";

        string CombQuery = @"SELECT * FROM dbo.Member;";

This worked perfectly

WMTS
  • 53
  • 1
  • 1
  • 12