Click here to Skip to main content
15,888,286 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to send sms to distinct users from the database. Code works perfectly fine on the local host. But when I upload it to the server, it works but it is sending duplicate messages. That is if there are 3 messages to 3 different people, each person gets his message twice or thrice instead of once. This is the code I have used. Please help
VB
Public Function DoWebRequest(ByVal url) As String
             On Error GoTo err_DoWebRequest
        Dim objXML As Object
        objXML = CreateObject("Microsoft.XMLHTTP")
        objXML.Open("GET", url, False)
        objXML.Send()
        If (objXML.Status = 404) Then
            DoWebRequest = "404 Error"
        Else
            DoWebRequest = objXML.ResponseText
        End If
        objXML = Nothing
        Exit Function
err_DoWebRequest:
        DoWebRequest = "ERROR"
        Exit Function
    End Function
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
 Dim strUrl As String
        Dim strResp As String
        Dim var1 As String
        Dim var2 As String
        Dim cnn As String = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
        Dim da As New System.Data.SqlClient.SqlDataAdapter("SELECT * FROM crm", cnn)
        Dim ds As New System.Data.DataSet()
        da.Fill(ds, "crm")
        Dim dr As System.Data.DataRow
        For Each dr In ds.Tables("crm").Rows
            var1 = dr("Mobile").ToString()
            var2 = dr("MsgCode").ToString()
                      strUrl = "http://enterprise.smsgupshup.com/GatewayAPI/rest?method=SendMessage&send_to=" & var1 & "&msg=" & var2  & "&msg_type=TEXT&userid=XXXXXXXXXauth_scheme=plain&password=XXXXXXX&v=1.1&format=text"
  strResp = DoWebRequest(strUrl)
        Next
End Sub
Posted

1 solution

If you are using a different database on your server, it may be that your server database has more than one row for the same mobile number. Check the rows of the crm table in your server.
 
Share this answer
 
Comments
Myth31 1-Aug-11 8:45am    
No I checked the crm table. Its fine

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900