Receiving and converting text to data...

Last post 10-28-2008 4:26 PM by allanhorwitz. 4 replies.

Sort Posts:

  • Receiving and converting text to data...

    10-28-2008, 7:17 AM
    • Member
      7 point Member
    • kikiriki
    • Member since 10-28-2008, 11:01 AM
    • Posts 31
    Hi to everybody (this is my first post here), I have some experiences in C++, C#, SQL, WEB designing and development, but I'm pretty new in ASP.NET. The problem I want to solve is: How to receive a message (textual, ready for converting to data for database) from other server, and fill the SQL database with it. So application needs to wait (listening) for messages, and when it comes receive it and use it for database. If you can explain me what is procedure to do it, or to direct me where to search for solution. Thanks.
  • Re: Receiving and converting text to data...

    10-28-2008, 8:21 AM
    • Participant
      1,855 point Participant
    • nKognito
    • Member since 03-06-2008, 5:11 AM
    • Posts 349

    If you need it as a web site application you can do it this way: create some aspx page and in code behind check for PostBack. In case of IsPostBack is true - retrieve msg (for example) parameter from Request array and put it into your database. From other side (application which will send a message) have to create a POST request to your page.

    Code for aspx "listener":

     

    protected void Page_Load(object sender, EventArgs e)
    {
         if (IsPostBack)
         {
             if(Request["msg"] != null)
             {
                  string msg = Request["msg"].ToString();
                  // Code here to put a message to db
             }
         }
    }
     
    May the Force be with you
  • Re: Receiving and converting text to data...

    10-28-2008, 8:33 AM
    • Member
      35 point Member
    • jccastillo
    • Member since 06-25-2008, 10:05 AM
    • Colombia
    • Posts 38

    hy if you want recive information to the other server, you can send this informatio by url parametres, and after save to database for example

    this is your http://webserver/default.aspx?id1=1&id2=5

    in the load that your page you can recieved

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    If Not IsPostBack Then

    Dim id1, id2 as string

     id1= Request.QueryString("Id1")

     id2= Request.QueryString("Id2")

    end if

    and this informatio and after save to database, i hope help you?

     

    Juan Carlos Castillo
  • Re: Receiving and converting text to data...

    10-28-2008, 3:39 PM
    • Member
      7 point Member
    • kikiriki
    • Member since 10-28-2008, 11:01 AM
    • Posts 31

     Thanks guys,

    I prefer c# solution (as I use it more than VB), this seems OK, but does the sending application need to open my page (or the page is loaded on POST request), or this code works without it (in background)? So, if a sending server use my page's url parameters to send a message this code will take the message into string 'msg'. What if the message contain more than one field (separated with coma), and more than one recordset separated, let's say, with semi colon. How can I arrange it in more than one string, or is there any way to use ado .net to extract data from one string variable, in the table?

    And, is there any way to test the code using localhost, or local network, before I try it on server?

     Thank you again,

     

  • Re: Receiving and converting text to data...

    10-28-2008, 4:26 PM
    Answer
    • Contributor
      2,382 point Contributor
    • allanhorwitz
    • Member since 04-10-2008, 1:45 PM
    • Philadelphia, PA
    • Posts 517

    kikiriki:
    I prefer c# solution (as I use it more than VB), this seems OK,

    http://www.developerfusion.com/tools/convert/vb-to-csharp/

    protected void // ERROR: Handles clauses are not supported in C# Page_Load(object sender, System.EventArgs e) 
    { 
        
        if (!IsPostBack) { 
            
            string id1 = null; 
            string id2 = null; 
            
            id1 = Request.QueryString("Id1"); 
            
            id2 = Request.QueryString("Id2"); 
            
        } 
    } 
     
    Allan Horwitz
Page 1 of 1 (5 items)