locked
want to connect with remote sql server to mobile pocket pc RRS feed

  • Question

  • User-1512018276 posted

    hi,

     

    I am using mobile 5.0 pocket pc. i have developed one application and its running success fully. Now i want to fetch the data from remote server having sql sever 2008 or sql server 2005. here is the code for it

    private void button1_Click(object sender, EventArgs e)
            {
                try
                {
                    SqlConnection connection = new SqlConnection("Server=servername;Initial Catalog=dbname;User ID=username;Password=password;Integrated Security=false;");
                    SqlCommand command = connection.CreateCommand();
                    command.CommandText = "select top 1 id from empinfo";
                    connection.Open();
                    label1.Text = command.ExecuteScalar().ToString();
                    connection.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

     

    But i am getting the error that

    Specified SQL server not found:


    How to remove this error and how to fetch the data from remote server using sql server 2008 or sql server 2005

    Please help me out

    Monday, March 28, 2011 10:03 AM

All replies

  • User1943143334 posted

    Hi,

    Are u using emulator to test ur application. If yes, make sure, the emulator is connected to the interne, and try again.

    Check the following link, for connecting the Windows Mobile emulator to internet.

    http://blogs.msdn.com/b/akhune/archive/2005/11/16/493329.aspx

    Hope it helps u...

    Monday, March 28, 2011 11:37 AM
  • User-1512018276 posted

    hi,

    Thanks for answering. Yes i am using emulator and i have checked that its connected with internet. because i am able to view the site in  internet explorer in application device after debugging. but not able to get data from remote server

    What steps i should take to do this

    Tuesday, March 29, 2011 5:35 AM
  • User-986415543 posted

    its been a while that you asked the question however I wanted to reply with my solution to guide others who has the same problem with me.

    I was able to connect to internet with windows mobile emulator however I could not connect to sql server.

    I changed the connection string with bellow and it worked for me;

    SqlConnection connection = new SqlConnection("Server=serverIP,sqlServerPort;Initial Catalog=dbname;User ID=username;Password=password;Integrated Security=false;");

    SqlConnection connection = new SqlConnection("Server=192.168.1.4,1433;Initial Catalog=dbname;User ID=username;Password=password;Integrated Security=false;");

    Tuesday, January 14, 2014 4:58 AM
  • User-1217288770 posted

    CMURAT THANK'S For Your RESPONSE DUDDDDE !! You saved my life !!! It worked just fine after adding the port !!

    Tuesday, May 19, 2015 7:14 PM