A DLL is a library that contains code and data that can be used by more than one program at the same time. For example, in Windows operating systems, the Comdlg32 DLL performs common dialog box related functions. Therefore, each program can use the functionality that is contained in this DLL to implement an Open dialog box. This helps promote code reuse and efficient memory usage.
By using a DLL, a program can be modularized into separate components. For example, an accounting program may be sold by module. Each module can be loaded into the main program at run time if that module is installed. Because the modules are separate, the load time of the program is faster, and a module is only loaded when that functionality is requested.
Adding a Reference to a project in Visual Studio:
1. There are two ways to add a DLL. One way, Right click on the Project name in the Solution explorer Ã Click on Add Ã Click on Reference.
(If Solution Explorer is not displayed then enable by selecting " Options" under "Tools" menu on the ribbon Ã expand "Projects and Solution" Ã check " Always show solution"
2. Another way is Right Click on the References Ã Click on Add Reference
Connecting to SQLCE database using SQLCE.dll file:
Repeat the above steps:
Now to add SQLCE.dll file, follow the following steps:
If SQL Compact Edition is installed in your system then, check in the following path, for the dll file: "C:\Program Files (x86) \ Microsoft SQL Server Compact Edition\v4.0\Desktop". If the SQLCE is not installed in the system then download the respective DLL and add it in the references.
After adding DLL:
1. Include the library file of SQLCE Database:
After adding DLL file in the project, check whether the file was added by expanding the References in the Solution Explorer:
2. Create a SQLCE Connection object:
Datasource = The file path and name of the SQL Server Compact database. To indicate a relative path to the database from the application directory (While specifying the path of the file use escape sequence (\\).
Datasource = "F:\\All Files\\ContactManager.sdf;"
pwd = Specify password of the database file.
Datasource =" F:\\All Files \\ ContactManager.sdf; pwd=admin;"