Click here to Skip to main content
15,883,883 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
hello friends!!

I want to send data e.g imei no to server from windows mobile. we have asp.net application on the server . Please tell me how to send this and retrieve the sent data, so that we can insert it into database.
Thank you

[EDIT]

this what i have done. Client side program
C#
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;

namespace Client
{
    public partial class Form1 : Form
    {
        string url = "http://localhost/testwebsite/default.aspx?field1=name";
        public Form1()
        {
            InitializeComponent();
        }

        private void btn_Send_Click(object sender, EventArgs e)
        {
            try
            {
                HttpWebRequest req = (HttpWebRequest)WebRequest.Create(new Uri(url));
               
            }
            catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); }
        }
    }
}

Server side program:
C#
protected void Button1_Click(object sender, EventArgs e)
   {
       try
       {
           String s = Request.QueryString["field1"];
           Label1.Text = "value got:" + s.ToString();
       }
       catch (Exception ex) { Label1.Text = ex.Message.ToString(); }


   }

This i have done just for testing purpose.
but am getting the following error when click on the button in asp.net website
Object reference not set to an instance of an object.
Posted
Updated 7-Apr-11 9:51am
v4
Comments
pankajupadhyay29 5-Apr-11 14:00pm    
what you want?? To create a windows mobile application which communicate with server ??????????
Noel3090 5-Apr-11 15:01pm    
yes and then upload some data to website (asp.net) retrieve data from it and store it in database
walterhevedeich 7-Apr-11 21:59pm    
From what I understand, you want to pass IMIE NO from your client application to the website, and then, to the database. If I may ask, whats the purpose of having the data sent to the website first. Can you just send it directly to the database?

Use ASP.Net web service and call that service from your windows mobile application where you can get that information and in the web service you can write the code to save the data to db.

Following links might help you to get Device information in windows mobile application

http://www.codeguru.com/forum/showthread.php?t=444933[^]
http://social.msdn.microsoft.com/Forums/en-US/vssmartdevicesvbcs/thread/c10f1962-257f-449a-84be-bc4e25753099/[^]

Links for creating web service

Your first C# Web Service[^]
ASP.NET Web Service[^]

For a while if you don't want to go through creating web service then do one thing create a web service project in vs the helloword method will created for you

copy that and rename put a string parameter imieno and in function body save that value to db.
--Pankaj
 
Share this answer
 
v3
Comments
Noel3090 6-Apr-11 11:50am    
thanks pankaj..but the links which you have given provides information of getting imei no. i got the imei value but i want to send to server now. can u please help in this
pankajupadhyay29 6-Apr-11 13:05pm    
If you have the imei no then pass this to web service function.You can simply create a service reference to the service on server, and the web service will save this data to db.
pankajupadhyay29 6-Apr-11 13:05pm    
if you got any issue in creating web service or calling web service let me know.
Noel3090 6-Apr-11 13:24pm    
ya i am having trouble creating web service, this topic is new to me. please help
There is no such thing as "transfer data" to "just server". Usually, the Server is a machine. What it does totally depends on the software it runs, and there is nothing generic about it. You need to decide what your server-part software should do (and perhaps develop such software if a regular FTP or HTTP server is not what you need), only than you should think what a particular client part should do.

[EDIT]
Answering follow-up Question:
Now I understand the server is HTTP. I did not get why a regular Web client is not an options. Probably some local code (and the Mobile client system should be involved). In this case, you need to use the class System.Net.HttpWebRequest: send a request (using POST method, I presume) to the server. Check is all the API you use is available for your system. I found platform compatibility information on the help pages for Framework v.2.0, 3.0 and 3.5 (http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest(v=vs.90).aspx[^]), but by some reason not for 4.0. (maybe this version is not yet ready for this platform?). Anyway, I think it should be available on the Framework already installed on your mobile device.

Look at the code sample here: http://msdn.microsoft.com/en-us/library/system.net.webrequest.aspx[^]. This class is abstract, but run-time class will be System.Net.HttpWebRequest, as it will be constructed via the factory WebRequest.Create method which will select appropriate run-time by your URL.

The example above is just a skeleton.
I have found a more detailed sample for you, this time the one using "POST" method and actually sending some data. It should be very close to your client code. Here: http://msdn.microsoft.com/en-us/library/debx8sh9.aspx[^].

You can test it using some available running Web site.

—SA
 
Share this answer
 
v7
Comments
Noel3090 5-Apr-11 14:38pm    
thanks SAKryukov for the reply
But i mentioned above that we asp.net application on the server.. ie we need to send data to asp.net website and retrieve it and store it in database
Sergey Alexandrovich Kryukov 5-Apr-11 15:00pm    
Or, I see. Sorry, I did not pay attention. Still, it it a regular form with POST method? Why just using a Web browser in the mobile is not a solution? If it's something special, you should explain it...
--SA
Noel3090 6-Apr-11 11:35am    
i have windows mobile application. so i hv to retrieve imei no and send to server. And then insert the retrieved value in database. please help, i really cant understand how to do it
Sergey Alexandrovich Kryukov 6-Apr-11 16:47pm    
I updated the Answer. Please see the text after [EDIT]
--SA
Noel3090 7-Apr-11 8:56am    
but how to post data when you have windows mobile application? am not using browser.

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