1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to create my SMS application with a gateway

Discussion in 'C#' started by maxh69, Oct 24, 2012.

  1. maxh69

    maxh69 New Member

    Oct 24, 2012
    Likes Received:
    Trophy Points:
    Hi everyone,
    I need to create an SMS application for my website, and I already found some information at the official site of Ozeki NG SMS Gateway.

    I’m wondering how relevant this information is, and whether I should really choose Ozeki NG SMS Gateway, because I hear it is one of the most reliable and robust gateways on the market, and it also provides the capacity of 10 million messages that I need to send in one day. Do you think I should use it? And how relevant is this source code to my SMS application?

    Once the database has been prepared and the SMS Gateway has been setup you can use Visual Studio.NET to create your SMS application. In Visual Studio create a new project of "Windows Application" type. This application will provide a GUI for sending the SMS message. It will connect to the database server and will insert a new record when a message is sent to a mobile phone.

    In this application you should have a form, that can be used by the user of your app to compose the message. This form should contain a field for the recipient number and another field for the message text. The form will have a button that will initiate the sending process.

    To be able to connect to your database server you should include the "using System.Data.OleDb;" directive in the using section for your code. The code for sending the SMS message is written into the event handler of the button. In this code first we connect to the database using an OleDbConnection object. For the connection we use a standard connection string. If the connection is successful (the state equals ConnectionState.Open), we execute our SQL INSERT statement to insert the SMS message. To achieve this we compose the SQL statement and we use an OleDbCommand object to execute it.

         private void button1_Click(object sender, EventArgs e)
                    //Connect to the database
                    OleDbConnection conn = new OleDbConnection();
                    conn.ConnectionString = "Provider=SQLNCLI;Server=.\\;"+
                    "User ID=ozekiuser;password=ozekipass;Database=ozeki;Persist
                    Security Info=True";
                    if (conn.State == ConnectionState.Open)
                        //Send the message
                        OleDbCommand cmd = new OleDbCommand();
                        cmd.Connection = conn;
                        string SQLInsert =
                            "INSERT INTO "+
                            "ozekimessageout (receiver,msg,status) "+
                            "VALUES "+
                        cmd.CommandText = SQLInsert;
                        MessageBox.Show("Message sent");
                    //Disconnect from the database
                catch (Exception ex)

Share This Page