0

I am using Visual Studio 2012 with SQL Server Management Studio 2012, At very first I created a database named salesystem in SQL Server Management Studio 2012, I created views and tables also in SQL Server Management Studio 2012 ... Then

  1. I created a new Winform Project,

  2. Then I created a new Data connection in Server Explorer (Visually > Not by Coding) in Visual Studio 2012. Server Explorer > Add Connection > (In Server Name I gave . and selected my database from the combo box given there , I clicked TEST CONNECTION (It gave me Connection Successful !) then I clicked OK ).

  3. Then I created a NEW DATA SET by clicking on Solution Explorer > Add > New Item > Dataset.

  4. Then In Data Set I Dragged Tables from my Database. And started working with my Database.

Now the problem is that when i wish to publish my project, my database is not attached with it! What to Do Now???

  1. How can I publish this Application with my Database created in SQL Server Management Studio 2012??

  2. How can i reference my Database to my Winform Application?

  3. Do i have to reference it before publishing? If YES, then HOW????

  4. IF ... someone in one of you helped and solved my problem, then when I install this Application with database on my client PC, and install SQL Server 2008 Express OR SQL Server Management Studio 2012, will I have to give server name. In his PC?? After installing and running SQL Server Management Studio 2012???? If yes then, how can I configure database reference settings after my application is published?

I know this is a very long question but I am stuck very badly!!! Any Help Will Be Appreciated....

NOTE : I don't know any other method on how to make a database app in winforms in visual studio 2012 , so please try to help me in my way , Not by telling me to use SQL Compact or LOCAL Database in my app !!! I know it’s a tricky question!

Dave
  • 8,163
  • 11
  • 67
  • 103
Emad
  • 73
  • 3
  • 10
  • 3
    Okay, take a deep breath mate. You've missed a key point. What you have now is a client deployment, something else needs to either deploy sql server (as in install it in a known location) or to discover a sql server instance to deploy to, or may be both. That's why Visual Studio has it's own huge installer app that also say installs SQL Server Express. – Tony Hopkinson Sep 06 '13 at 11:37

2 Answers2

2

When you deploy you have to attach the file to the Applications Folder. I dont think you can do this with publish wizard so I'll advise you use

They have facilities to attach your database to the Applications Folder of your user.

Community
  • 1
  • 1
0

Actually your problem in your connection string
try this:

1- add a copy of your database to your debug file.(you can fine your database in

"C:\Program Files\Microsoft SQL Server[your instance name]\MSSQL\DATA[your database Name]")

2- modify your connection string (in app config )

Server=.\SQLExpress;AttachDbFilename=|DataDirectory|YourDB.mdf;
Database=YourDBname;Trusted_Connection=Yes;

3-try to deploy.

Note: the database version must be equal or lower of server instance version and this is manual way the better way but the better way to attache database to sql server in deployed PC

Eiaddar
  • 180
  • 1
  • 13
  • i didnt find my database there ... though when i open sql management studio it shows my databases .... – Emad Sep 06 '13 at 17:17
  • You told me to go in 1rst step to some directory , my directory is C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA there i have MASTER, MODEL , MSDBDATA , tempdb databases .... none of which i am concerned ! where i am now ??? – Emad Sep 06 '13 at 17:18
  • my App.config file is here – Emad Sep 06 '13 at 17:28
  • Did you create your Database By SQL Management Studio or Just attached it? – Eiaddar Sep 07 '13 at 04:56
  • if you created it you will find your db there else, else you find the db where you attached it just like northwind . use search in windows to find it. and then edit the connection string in data source section. – Eiaddar Sep 07 '13 at 05:07