Advertisement
pushrbx

Untitled

Oct 31st, 2013
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.19 KB | None | 0 0
  1. Requirements for the project: you need to have a sql server and visual studio 2012 installed.
  2. 1. Open the DocumentStorage.sln with visual studio.
  3.  
  4. 2. Make sure that all SQL Server Browser service is running by typing in the start menu search: services.msc (or Control Panel -> System Security -> Administrative Tools -> Services). When you see the services window look for the SQL Server Browser, and in the list next to its name you will see its status.
  5.  
  6. 3. In visual studio on the left hand side there will be the server explorer. If you can't see it then press CTRL + ALT + S or go to View -> Server Explorer.
  7.  
  8. 4. Add a new database connection. Image: http://imageshack.us/a/img189/4459/xvyy.jpg
  9.  
  10. 5. A new window pops up. Click on the down arrow next to the drop down menu. Image: http://imageshack.us/a/img713/1727/dizv.jpg
  11.  
  12. 6. Wait until it loads, and you have to see the lists of running SQL Server instances. You should see atleast the SQLEXPRESS name in the list. Choose one. Leave the authentication settings on their defaults. So Windows authentication. Under the "Connect to a database" section, in the first field type bookstore. That's going to be the name of our database and if it doesn't exist the visual studio will create it.
  13.  
  14. 7. Press "Test Connection". Image: http://imageshack.us/a/img823/1339/d1tj.jpg
  15.  
  16. 8. If it works, then press ok.
  17.  
  18. 9. Now in the server explorer you should see a new element under the Data Connections node, open it and right click on the "Tables" element and chooose New Query. Image: http://imageshack.us/a/img197/1832/ginc.jpg
  19.  
  20. 10. It opens a new empty sql document. Paste the following code in there: http://pastebin.com/30Kt4pAk
  21.  
  22. 11. Press the Execute button: http://imageshack.us/a/img29/9008/lxvq.jpg
  23.  
  24. 12. If it succeeds then go to the Solution Explorer window on the right hand side (or left hand side, it depends on your settings, but if you don't see it go to View -> Solution Explorer in the menu on the top) and find the DocumentStorage project, and under the Properties folder there will be the Settings.settings. Open it and you will see the following text: "Data Source=M-DEVMACHINE\DEVSQL;Initial Catalog=bookstore;Integrated Security=True".
  25.  
  26. 13. Edit the "Data Source=M-DEVMACHINE\DEVSQL" part to "Data Source=<your machine name>\SQLEXPRESS". Also you can find the "<your machine name>\SQLEXPRESS" string in the server explorer under the Data connections node, but be careful, just use the string until the "dot" in it. Image: http://img33.imageshack.us/img33/4184/vuqh.jpg
  27. On the image you can see the "m-devmachine\devsql.bookstore" string. In that case you only need the "m-devmachine\devsql".
  28.  
  29. 14. Now build the solution: Go to Build -> Build Solution.
  30.  
  31. 15. Now find the UnitTest1.cs file in the Solution explorer and open it.
  32.  
  33. 14. Go to Test -> Run -> All tests. Image: http://img197.imageshack.us/img197/4548/ynld.jpg
  34.  
  35. 15. If the test succeeds then the database connection works perfectly.
  36.  
  37. NOTE: I went for the dynamic library solution (so the compiled binary is a DLL), not for an executable application, that's why the unit test project is the only way to run the project (I mean test it...). The reason for my choice is the flexibility and the reusability.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement