Monday, 16 March 2015

Create a new SQL Server Compact 4.0 database using Microsoft Visual Studio 2012.

Following are simple steps to create a new SQL Server Compact 4.0 database using Microsoft Visual Studio 2012. 

First make your desktop or web application project choosing any language VB.NET or C#.NET  in visual Studio 2012 then go on the View menu, click Server Explorer/Database Explorer.


Now right-click "Data Connections" option given in the server explorer window then click "Add Connection" .


Now when the "Add Connection" dialog box opens, set that the Data Source as Microsoft SQL Server Compact 4.0 which is the .NET Framework Data Provider for SQL Server Compact 4.0 and click "continue".


Don't change the default selection of "My Computer" in Data Source area. 
In the "Connection Properties" area enter database file name then Click the "Create" button and in the newly opened dialog box, only specify the file path by clicking the "brows" button , and password of the new database. You can also choose to encrypt the data if you want otherwise leave the default selection as it. Click "ok" to return to the Add Connection dialog box.


Click "Test Connection" button to verify connectivity to the new database. Click OK after message prompt "Test connection succeeded ".Your new database is now connected. 


Now you can expand the already connected .sdf database file you created and right-click the "Tables" node to start creating new tables.

No comments:

Post a Comment