Program to send SMS

About | Contact us

 
 

Write incoming SMS in a database

You can use Headwind GSM Modem Driver to place incoming short messages in a database. This example is related to the MySQL database. However, you can use MS SQL database as well (there is a command-line utility sqlcmd.exe, which places data in the database).

To place SMS in a database, you need to install the database first. Use the Windows package of MySQL from http://www.mysql.com.

After the MySQL database is installed, do the following steps to setup a handler:

  • Create the database by running MySQL client and typing the following commands:

    CREATE DATABASE smsbase;
    USE smsbase;
    CREATE TABLE smstable (smstime DATETIME, sender VARCHAR(255), body VARCHAR(255));

     

  • Open the control panel of Headwind GSM Modem Driver by double-clicking the application icon and select the "Handlers" tab;
  • Click "Add"; a "Handler" dialog will be opened;
  • Type the following command in the "Command" field (check the path to the MySQL client!):

    echo insert into smstable values(curtime(), '_FROM_','_BODY_'); | "c:\Program Files\mysql5.0.51b\mysql" smsbase

     

  • Click "OK". You will see that the new handler appears in a list.

The handler setup is complete. Send a short message to the mobile phone number of a GSM device connected to the PC. You will see a balloon tip notifying you that the message has been handled. To check that the SMS has been written in the database, run the MySQL client and type the following commands:

USE smsbase;
SELECT * FROM smstable;

The result of selection must contain the time, the sender address and the SMS body.