locked
coonection to database RRS feed

  • Question

  • User-565334428 posted

    my data source is Data Source=(LocalDB)\v11.0;AttachDbFilename="C:\Users\MJais\Documents\Visual Studio 2013\E_Tutor_Manager\E_Tutor_Manager\E_Tutor_Manager\App_Data\Database1.mdf";Integrated Security=True;User Instance=False

    but i am having error if i connect what should I do 

    it is visual studio 2013

    Wednesday, December 2, 2015 8:05 AM

Answers

  • User1644755831 posted

    Hello Maryam Jamil,

    Please see: Creating a Connection String and Working with SQL Server LocalDB

    <add name="MovieDBContext" 
       connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Movies.mdf;Integrated Security=True" 
       providerName="System.Data.SqlClient" 
    /> 

    Data Directory means the app data in your project folder put your mdf file in App_Data there.

    With Regards,

    Krunal Parekh

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, December 3, 2015 1:55 AM
  • User753101303 posted

    Hi,

    Maryam Jamil

    what should I do

    You should never post about an error without telling what it is ;-)

    More seriously, you could have tons of reason for a failure and it is not always visible in what you post. So rather than letting others to guess what is the error you have, if you tell which error you have it allows to quickyl narrow down what happens to few or even a single cause...

    Not directly related but using an absolute path for the data file is likely a bad practice (though it could be unrelated to your issue).

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 8, 2015 12:46 PM

All replies

  • User-821857111 posted

    Post your error message, please.

    Wednesday, December 2, 2015 1:05 PM
  • User1644755831 posted

    Hello Maryam Jamil,

    Please see: Creating a Connection String and Working with SQL Server LocalDB

    <add name="MovieDBContext" 
       connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Movies.mdf;Integrated Security=True" 
       providerName="System.Data.SqlClient" 
    /> 

    Data Directory means the app data in your project folder put your mdf file in App_Data there.

    With Regards,

    Krunal Parekh

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, December 3, 2015 1:55 AM
  • User753101303 posted

    Hi,

    Maryam Jamil

    what should I do

    You should never post about an error without telling what it is ;-)

    More seriously, you could have tons of reason for a failure and it is not always visible in what you post. So rather than letting others to guess what is the error you have, if you tell which error you have it allows to quickyl narrow down what happens to few or even a single cause...

    Not directly related but using an absolute path for the data file is likely a bad practice (though it could be unrelated to your issue).

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 8, 2015 12:46 PM