pushrbx icon

Untitled

pushrbx | PRO | 11/01/13 12:08:16 AM UTC | 0 ⭐ | 388 👁️ | Never ⏰ | []
text |

3.19 KB

|

None

|

0 👍

/

0 👎

Requirements for the project:  you need to have a sql  server and visual studio 2012 installed.
1. Open the DocumentStorage.sln with visual studio.
 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.
 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.
 4. Add a new database connection. Image: http://imageshack.us/a/img189/4459/xvyy.jpg
 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
 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.
 7. Press "Test Connection". Image: http://imageshack.us/a/img823/1339/d1tj.jpg
 8. If it works, then press ok.
 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
 10. It opens a new empty sql document. Paste the following code in there: http://pastebin.com/30Kt4pAk
 11. Press the Execute button: http://imageshack.us/a/img29/9008/lxvq.jpg
 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".
 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
On the image you can see the "m-devmachine\devsql.bookstore" string. In that case you only need the "m-devmachine\devsql".
 14. Now build the solution: Go to Build -> Build Solution. 
 15. Now find the UnitTest1.cs file in the Solution explorer and open it.
 14. Go to Test -> Run -> All tests. Image: http://img197.imageshack.us/img197/4548/ynld.jpg
 15. If the test succeeds then the database connection works perfectly.
 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.

Comments