deploying window application with .mdf

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • smart aditya
    New Member
    • Oct 2008
    • 5

    deploying window application with .mdf

    hello everyone!!!!

    I have window application with "student.md f " with it.
    I deployed this project successfully. Its ".exe" is running successfully on my system as connection string has exact path to "student.md f ".

    Connection string is=

    SqlConnection con1 = new SqlConnection(" Data Source=.\\SQLEX PRESS;AttachDbF ilename=D:\\Win dowsFormsApplic ation1\\student .mdf;Integrated Security=True;U ser Instance=True") ;


    but when i run ".exe" on other system, error::'connect ion to database fails' comes.


    so how can i deploy "student.md f" along with application and than what will be connection string in that case ??

    thanks in advance...
  • cloud255
    Recognized Expert Contributor
    • Jun 2008
    • 427

    #2
    You need to include the database along with your application, that is have it install on the client machine and reference it using a relative path eg:

    Your install folder might be as follows
    MyApp\bin\
    MyApp\bin\data

    Installing the database to the \data folder will allow you to use a relative path to the DB in your connection string

    SqlConnection con1 = new SqlConnection(" Data Source=.\\SQLEX PRESS;AttachDbF ilename=~\\data \\student.mdf;I ntegrated Security=True;U ser Instance=True") ;

    You get an error as the database filepath you supplied is invalid on the client machine, i.e. on the client machine student.mdf does not exist in D:\\WindowsF ormsApplication 1

    Comment

    • smart aditya
      New Member
      • Oct 2008
      • 5

      #3
      Thank you sir.
      Its working !!!!

      Comment

      Working...