Search by Tags

How to use SQL Database in VCSharp

 
Applicable for

Compare with Revision



Subscribe for this article updates

SQL (Structured Query Language) is a special-purpose programming language designed for managing data held in a relational database management system (RDBMS). The scope of SQL includes data insert, query, update and delete, schema creation and modification and data access control.

Use Cases:

  • Inventory manager.
  • Billing station.
  • Automated Parking System.
  • Attendance system.
  • and many more..

Download and Installation

  • Download demo source code from here.
  • Download and Install .NET Compact Framework directly to the FlashDisk of the device from here.
  • Download and Install SQL CE directly to the FlashDisk of the device from here.

Steps to make SQL database in Visual studio 2008

  • Goto Data in Menu Bar in VS2008 then click Add New Database. Following window will open:-

  • Click on Next and then New Connection, Type Database name and test Connection.

  • Press OK, then next and then Finish.

  • In server Explorer Right Click on Tables under sql_demo.sdf and click create Table. Following window will come enter table name and column, then press OK.

NOTE: you may not need to make database for the demo project as its already provided in the sql_demo folder.

Steps to run the demo

  • Navigate to Solution Explorer in Visual Studio > Right Click on sql_demo > Properties > Devices
  • Uncheck Deploy the Latest version of the .NET Compact Framework (including Service Packs).
  • Bulid and deploy solution.
  • Run sql_demo.exe from Program File folder on Toradex module.

Output


  • Press SHOW button and you can see demo_table

  • Select row and Press DELETE button, selected row will be deleted.

Similarly

  • To insert, enter ID and Name in corresponding textbox and press INSERT button.
  • To modify, select row and click MODIFY and then enter ID and NAME.
  • To search, enter ID and then press SEARCH button.
  • To sort, simply press SORT button,it will get sorted.

Notes:

For connecting to Microsoft SQL Server running on a remote server/desktop machine, while running the client on a Colibri module, we were able to connect to the Microsoft SQL Server over Ethernet using a C# application. For this scenario, if "Can't find PInvoke DLL 'dbnetlib.dll'" error is encountered, the dbnetlib.dll needs to be copied from the path C:\Program Files\Microsoft SQL Server Compact Edition\v3.5\Devices\Client\wce500\armv4i to the application folder from where the application is being run on the module.