Click here to Skip to main content
15,902,893 members
Home / Discussions / C#
   

C#

 
QuestionAI Pin
Member 1036314518-Nov-13 23:40
Member 1036314518-Nov-13 23:40 
QuestionRe: AI Pin
Richard MacCutchan19-Nov-13 0:01
mveRichard MacCutchan19-Nov-13 0:01 
AnswerRe: AI Pin
BillWoodruff19-Nov-13 6:34
professionalBillWoodruff19-Nov-13 6:34 
GeneralRe: AI Pin
Mycroft Holmes19-Nov-13 13:40
professionalMycroft Holmes19-Nov-13 13:40 
Questionwinform to wpf Pin
Member 1026351918-Nov-13 22:42
Member 1026351918-Nov-13 22:42 
AnswerRe: winform to wpf Pin
Abhinav S18-Nov-13 22:44
Abhinav S18-Nov-13 22:44 
QuestionRe: winform to wpf Pin
Eddy Vluggen19-Nov-13 0:33
professionalEddy Vluggen19-Nov-13 0:33 
QuestionC# Com Interface Pin
Rakesh_Ranjan_Incadea18-Nov-13 21:06
Rakesh_Ranjan_Incadea18-Nov-13 21:06 
Hi friend

I am creating a com interface , It created , but when i am using it with different platform ,interface is not created within that application.

Please help me where i am wrong.

Code is as follow :

using System;
using System.Runtime.InteropServices;
using System.IO;
using System.Text;
using System.Data.SqlClient;
using System.Net;



namespace SMSApp
{
    [Guid("694C1820-04B6-4988-928F-FD858B95C880")]
    public interface SendSMSInterface
    {
        [DispId(1)]
        void Init(string userid, string password);
        [DispId(2)]
        bool ExecuteSelectCommand(string selCommand);
        [DispId(3)]
        bool NextRow();
        [DispId(4)]
        void ExecuteNonSelectCommand(string insCommand);
        [DispId(5)]
        string GetColumnData(int pos);
        [DispId(6)]
        string sendMessage(string user, string password, string customer, string cardno, string MobileNo, string CreditPt, string DebitPt, string balancept);
        [DispId(7)]
        string sendSmsFirstTime(string user, string password, string customer, string cardno, string MobileNo, string balancept);

    }

    //interface Database_COMObjectEvents 
    [Guid("47C976E0-C208-4740-AC42-41212D3C34F0"),
    InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
    public interface DBCOM_Events
    {
    }


    [Guid("9E5E5FB2-219D-4ee7-AB27-E4DBED8E123E"),
    ClassInterface(ClassInterfaceType.None),
    ComSourceInterfaces(typeof(DBCOM_Events))]

    public class SendSMS : SendSMSInterface
    {
        private SqlConnection myConnection = null;
        SqlDataReader myReader = null;

        public SendSMS()
        {
        }

        public void Init(string userid, string password)
        {
            try
            {
                string myConnectString = "user id=" + userid + ";password=" + password +
                    ";Database=NorthWind;Server=SKYWALKER;Connect Timeout=30";
                myConnection = new SqlConnection(myConnectString);
                myConnection.Open();
                //MessageBox.Show("CONNECTED");
            }
            catch (Exception)
            {
                //MessageBox.Show(e.Message);
            }
        }

        public bool ExecuteSelectCommand(string selCommand)
        {
            if (myReader != null)
                myReader.Close();

            SqlCommand myCommand = new SqlCommand(selCommand);
            myCommand.Connection = myConnection;
            myCommand.ExecuteNonQuery();
            myReader = myCommand.ExecuteReader();
            return true;
        }

        public bool NextRow()
        {
            if (!myReader.Read())
            {
                myReader.Close();
                return false;
            }
            return true;
        }

        public string GetColumnData(int pos)
        {
            Object obj = myReader.GetValue(pos);
            if (obj == null) return "";
            return obj.ToString();
        }

        public void ExecuteNonSelectCommand(string insCommand)
        {
            SqlCommand myCommand = new SqlCommand(insCommand, myConnection);
            int retRows = myCommand.ExecuteNonQuery();
        }

        public string sendMessage(string user, string password, string customer, string cardno, string MobileNo, string CreditPt, string DebitPt, string balancept)
        {
            UnicodeEncoding unicode = new UnicodeEncoding();
            string strUrl = "http://api.mVaayoo.com/mvaayooapi/MessageCompose?user=";
            string strUr2 = user + ':' + password;
            string strUr3 = "&senderID=ETHOSW&receipientno=";
            string strUr4 = MobileNo + "&msgtxt=";
            string Strur5 = "Dear " + customer + " , thank u for using ur Club Echo card no. " + cardno + " . " + DebitPt + " Pts dr " + "%26 " + CreditPt + " pts cr to ur card. A/c Bal " + balancept + " pts.";
            string finalurl = strUrl + strUr2 + strUr3 + strUr4 + Strur5;
            WebRequest request = HttpWebRequest.Create(finalurl);
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            Stream s = (Stream)response.GetResponseStream();
            StreamReader readStream = new StreamReader(s);
            string dataString = readStream.ReadToEnd();
            string responsemsg = finalurl;
            //response.StatusDescription.ToString(); 

            response.Close();
            s.Close();
            readStream.Close();
            return (responsemsg);

        }

        public string sendSmsFirstTime(string user, string password, string customer, string cardno, string MobileNo, string balancept)
        {
            UnicodeEncoding unicode = new UnicodeEncoding();
            string strUrl = "http://api.mVaayoo.com/mvaayooapi/MessageCompose?user=";
            string strUr2 = user + ':' + password;
            string strUr3 = "&senderID=ETHOSW&receipientno=";
            string strUr4 = MobileNo + "&msgtxt=";
            string Strur5 = "Dear " + customer + " , thank u for shopping with us. Your card no. is " + cardno + " . A/c Bal is " + balancept + " points.";
            string finalurl = strUrl + strUr2 + strUr3 + strUr4 + Strur5;
            WebRequest request = HttpWebRequest.Create(finalurl);
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            Stream s = (Stream)response.GetResponseStream();
            StreamReader readStream = new StreamReader(s);
            string dataString = readStream.ReadToEnd();
            string responsemsg = finalurl;

            //response.StatusDescription.ToString(); 

            response.Close();
            s.Close();
            readStream.Close();
            return (responsemsg);

        }

AnswerRe: C# Com Interface Pin
Marco Bertschi18-Nov-13 21:33
protectorMarco Bertschi18-Nov-13 21:33 
AnswerRe: C# Com Interface Pin
Bernhard Hiller18-Nov-13 22:02
Bernhard Hiller18-Nov-13 22:02 
GeneralRe: C# Com Interface Pin
Rakesh_Ranjan_Incadea18-Nov-13 22:40
Rakesh_Ranjan_Incadea18-Nov-13 22:40 
AnswerRe: C# Com Interface Pin
Pete O'Hanlon18-Nov-13 22:10
mvePete O'Hanlon18-Nov-13 22:10 
GeneralRe: C# Com Interface Pin
Rakesh_Ranjan_Incadea18-Nov-13 22:37
Rakesh_Ranjan_Incadea18-Nov-13 22:37 
AnswerRe: C# Com Interface Pin
Pete O'Hanlon18-Nov-13 22:56
mvePete O'Hanlon18-Nov-13 22:56 
QuestionHow to insert some text rows before export a datatable to an excel file Pin
botngot8318-Nov-13 21:00
botngot8318-Nov-13 21:00 
AnswerRe: How to insert some text rows before export a datatable to an excel file Pin
Bernhard Hiller18-Nov-13 22:05
Bernhard Hiller18-Nov-13 22:05 
QuestionC# game/physics engine Pin
petter201218-Nov-13 3:55
petter201218-Nov-13 3:55 
AnswerRe: C# game/physics engine Pin
Richard MacCutchan18-Nov-13 5:44
mveRichard MacCutchan18-Nov-13 5:44 
GeneralRe: C# game/physics engine Pin
petter201218-Nov-13 12:18
petter201218-Nov-13 12:18 
AnswerRe: C# game/physics engine Pin
Ron Beyer18-Nov-13 5:52
professionalRon Beyer18-Nov-13 5:52 
GeneralRe: C# game/physics engine Pin
petter201218-Nov-13 12:15
petter201218-Nov-13 12:15 
AnswerRe: C# game/physics engine Pin
Pete O'Hanlon18-Nov-13 6:08
mvePete O'Hanlon18-Nov-13 6:08 
GeneralRe: C# game/physics engine Pin
petter201218-Nov-13 12:19
petter201218-Nov-13 12:19 
AnswerRe: C# game/physics engine Pin
_Maxxx_18-Nov-13 15:24
professional_Maxxx_18-Nov-13 15:24 
GeneralRe: C# game/physics engine Pin
petter201218-Nov-13 23:54
petter201218-Nov-13 23:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.