Send SMS messages from Microsoft SQL Server

In this chapter you can learn
how to send and receive SMS messages using the Microsoft SQL database server.
The solution uses the Ozeki NG - SMS Gateway software installed on your PC. The
solution uses the following database connection string to connect to the database
server:

Here is a quick overview of how this solution is going to work: First you create
two database tables: ozekimessageout and ozekimessagein in MS SQL.
Then you install and configure Ozeki NG SMS Gateway, to connect to MS SQL and
to use these database tables for sending and receiving messages. Once you
have the configuration completed, you can send an SMS message by creating a
record in the ozekimessageout database table using an SQL INSERT. Ozeki NG
will read this record using an SQL SELECT and will send your SMS message
using a GSM modem attached to the PC or using an IP SMS connection.

To do this you have to Download and
Install Ozeki NG SMS Gateway. After installation you have to log into
the SMS gateway using an Internet Explorer (or Firefox)
Browser by typing http://127.0.0.1:9501/ and supplying admin as the
login name and abc123 as the password. (Hint: do not forget to change
your password!). After login, go to the "Users and Applications/Add User" menu
item and click on Install next to the database user (Figure 2).

Figure 2 - Install database user

The last step of the installation is to enter a name for this user. For example
enter sql1 (Figure 3). You can type any name here.

Ozeki NG uses an ADO/OleDB connection to access you SQL Database server.
To setup this connection select OleDb as the connection type and
enter the following connection string into the connection string textbox.
Connection string:

Please note, that you must modify the
variables in the connection string according to your system.

Figure 4 - Specifying the connection string for the MS SQL database

After you have configured the SQL connection string, click OK. By clicking OK
Ozeki NG SMS Gateway will try to connect to your database server. You can verify
the connection results in the events form. The events form can be accessed
by clicking on the appropriate link (Figure 5).

Figure 5 - SQL Server events.

If the connection is successful, you can send an SMS message
by placing a record into the ozekimessageout database table.

Step 4 - Enable detailed SQL login

At this point you are ready to send your first SMS, but before you do, you
should enable SQL logging to see what the SMS Gateway is doing to get your
message. You can enable SQL logging on the Logging tab of the SQL User
configuration form (Figure 6).

Figure 6 - Enable SQL Logging

Step 5 - Send your first SMS message

To send your first SMS message you should insert a record into the ozekimessagout
database table using the following SQL command:

After you have inserted the record into the database, you should be able to
verify that Ozeki NG has picked up the message for sending. You can do this
by taking a look in the events form of the user (Figure 7).

Figure 7 - User events after successful sending

If everything goes well you should see the following entries in the log: