Ozeki NG SMS Gateway logo OZEKI NG SMS Gateway
"The World's most reliable SMS gateway software!"
info@ozekisms.com
Tel.: 00 36 52 532 731
SMS Gateway to send SMS via GSM modem or IP SMS connection Overview SMS Gateway to send SMS via GSM modem or IP SMS connection SMS Gateway to send SMS via GSM modem or IP SMS connection Quick start SMS Gateway to send SMS via GSM modem or IP SMS connection SMS Gateway to send SMS via GSM modem or IP SMS connection Download SMS Gateway to send SMS via GSM modem or IP SMS connection SMS Gateway to send SMS via GSM modem or IP SMS connection Manual SMS Gateway to send SMS via GSM modem or IP SMS connection SMS Gateway to send SMS via GSM modem or IP SMS connection How to buy SMS Gateway to send SMS via GSM modem or IP SMS connection SMS Gateway to send SMS via GSM modem or IP SMS connection FAQ SMS Gateway to send SMS via GSM modem or IP SMS connection SMS Gateway to send SMS via GSM modem or IP SMS connection Contact Us SMS Gateway to send SMS via GSM modem or IP SMS connection
OZEKI NG SMS Gateway - Product Guide

ASP user setup Contents | SearchE-mail to SMS alert

Home > Product Manual > Examples and Solutions > SMS Pin game > ASP Source

SMS Gateway SMS Gateway Home

  Product Manual
  Introduction
  SMS technology
  Installation Guide
  User Guide
  Developers Guide
  Examples and Solutions
  Telephone networks
  SMS Pin game
  Database
  ASP user setup
  ASP Source
  E-mail to SMS alert
  2 way SMS to Email gateway
  SMS Order System
  Least Cost Routing
  SMS Load Balancing
  Asterisk PBX SMS
  SQL SMS Gateway
  SMS Service Provider
  Service Provider
  SMS PIN code query
  SMS Counter game
  SMS newsgroup
  Distributed SMS
  SMS Menu
  Google maps
  Forwarding
  Birthday greeting - SQL Express
  Birthday greeting - MySQL
  Birthday greeting - Oracle
  Instant brochure - MMS autoreply
  Alphabet letter game
  SMS sport betting service
  E-mail about outgoing SMS messages
  SMS Information Menu
  Email to SMS feature
  Reminder example
  Bulk SMS Client
  Bulk SMS to a given phone number range
  Filtering phone numbers
  Ozeki Phone Sytem PBX SMS
  Autoreply voucher example
  Appendix
  FAQ
  Feature list
  Commercial Information
  Search
  Cookie policy
 


Automated phone calls?
Ozeki Phone System XE VoIP PBX software is an advanced PBX built for automated voice calls and 2 way SMS messaging. It has outstanding APIs for software developers. It can be used for:

Phone calls from SQL
Phone calls from HTTP
Voice and SMS applications

Callcenter developers
If you are working on telephone solutions, please check out the Ozeki VoIP SIP SDK.
It can be used to create VoIP client and server software.

Contact Us!
If you wish to get further information, do not hesitate to contact us!

E-mail: info@ozekisms.com

If you have a technical question, please submit a support request on-line.

ASP Script for creating pin game

This page gives you the source code for an ASP script, that is used in the SMS PIN Game demo.


<%@ Page Language="C#"%>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Common" %>
<%@ Import Namespace="System.Data.SqlClient" %>

<%
/************************************************************
 * copy the properties of the incoming SMS into local variables
 ************************************************************/

    string sender = Request.QueryString["sender"];
    string receiver = Request.QueryString["receiver"];
    string messagedata = Request.QueryString["messagedata"];
    string messageid = Request.QueryString["messageid"];
    string messagetype = Request.QueryString["messagetype"];
    string senttime = Request.QueryString["senttime"];
    string receivedtime = Request.QueryString["receivedtime"];
    string serviceprovider = Request.QueryString["operatornames"];

    string respmsg = "Hello, the following message was received: "+messagedata+
                     ". The message was sent at " + senttime;

/************************************************************
* Connect to the database
***********************************************************/
    bool connectedToDb;
    SqlConnection conn = new SqlConnection();;

    try
    {
        string sServer = ".\\SQLEXPRESS";
        string sUser = "ozekiuser";
        string sPwd = "ozekipass";
        string sDB = "ozeki";
        string connectionString = "Server=" + sServer + ";User ID=" + sUser + ";" +
        "password=" + sPwd + ";Database=" + sDB + ";Persist Security Info=True";

        conn.ConnectionString = connectionString;
        conn.Open();
        connectedToDb = true;
    }
    catch (Exception e)
    {
        respmsg = "Cannot connect to database." + e.Message;
        connectedToDb = false;
    }

/************************************************************
* Create database tables if they do not exist
***********************************************************/

    if (connectedToDb)
    {
        string sql1 =
        "if not exists(select * from INFORMATION_SCHEMA.tables where TABLE_NAME = 'pincode') "+
            "  CREATE TABLE pincode ( "+
                "id int IDENTITY (1,1),"+
                "pincode varchar(30),"+
                "response varchar(160),"+
                "used varchar(1)"+
                ")";

        try {
            SqlCommand cmd1 = conn.CreateCommand();
            cmd1.CommandText = sql1;
            cmd1.ExecuteNonQuery();
        } catch (Exception exp) {
            respmsg = "Cannot create database table: "+exp.Message;
        }
    }

/************************************************************
* Put some test data into the database
***********************************************************/
    if (connectedToDb)
    {
        string sql2 =
        "if not exists(select * from pincode) " +
            "begin " +
            "  INSERT INTO pincode (pincode,response,used ) VALUES ('3345','The treasure is behind the picture on the wall','0');" +
            "  INSERT INTO pincode (pincode,response,used ) VALUES ('4578','The treasure is under the pillow','0');" +
            "end";

        try {
            SqlCommand cmd2 = conn.CreateCommand();
            cmd2.CommandText = sql2;
            cmd2.ExecuteNonQuery();
        } catch (Exception exp) {
            respmsg = "Cannot create test data: "+exp.Message;
        }
    }

/************************************************************
* Process incoming message
***********************************************************/
    if (connectedToDb)
    {
        string pincode = messagedata.ToLower().Trim();

        string sql3 = "select used,response from pincode where pincode='" + pincode + "'";
        try
        {
            SqlCommand cmd3 = conn.CreateCommand();
            cmd3.CommandText = sql3;
            DbDataReader reader = cmd3.ExecuteReader();
            if (!reader.Read())
            {
                respmsg = "Invalid pin code '" + pincode + "'.";
                reader.Close();
            }
            else
            {
                string used = reader.GetValue(0).ToString();
                string treasurelocation = reader.GetValue(1).ToString();
                reader.Close();

                if (used != "0")
                {
                    respmsg = "The PIN code is correct, but this treasure has been taken.";
                }
                else
                {
                    respmsg = treasurelocation;
                    //update the database to mark the treasure as taken
                    SqlCommand cmd4 = conn.CreateCommand();
                    cmd4.CommandText = "update pincode set used='1' where pincode='" + pincode + "'";
                    cmd4.ExecuteNonQuery();
                }
            }
            //Close database connection
            conn.Close();

        }
        catch (Exception exp)
        {
            respmsg = "Invalid pin code. It could not be processed by the database. " + exp.Message;
        }
    }


//************************************************************
//create the response message(s). Format description:
//http://www.ozekisms.com/index.php?owpn=355
//************************************************************

string destnum = sender;
string resptype = "SMS:TEXT";
string resp = "{"+resptype+"}{}{}{"+destnum+"}{"+respmsg+"}";

Response.Write(resp);

%>



Dig deeper!
People who read this also read...





Next page: E-mail to SMS alert
Copyright © 2000 - 2017 Ozeki Informatics Ltd.
All rights reserved

Software PBX for Windows | VoIP SDK   |   Legal information   |   Privacy policy   |   Terms of use
Please, address your inquiries to info@ozekisms.com