Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. TCP/IP connexion failed in csharp smart device

TCP/IP connexion failed in csharp smart device

Scheduled Pinned Locked Moved C#
csharpdatabasehelpquestionhtml
33 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Michel Godfroid

    Ah the joy of developing for mobile! X| We can't read the full exception (your screen is too small). Put a breakpoint at the exception statement, and examine the 'ex' variable when the expression occurs.

    T Offline
    T Offline
    Tunisien86
    wrote on last edited by
    #21

    Hi Michel, when running the exception is :

    NULLREFERENCEEXCEPTION IS UNHANDLED
    Null ReferenceException

    and it point to this statement of my code:

    dr.Close();

    Thanks

    M 1 Reply Last reply
    0
    • T Tunisien86

      Hi Michel, when running the exception is :

      NULLREFERENCEEXCEPTION IS UNHANDLED
      Null ReferenceException

      and it point to this statement of my code:

      dr.Close();

      Thanks

      M Offline
      M Offline
      Michel Godfroid
      wrote on last edited by
      #22

      No, that's another exception. It happens because your try block never executed succesfully. put a breakpoint at MessageBox.Show(ex.Message); and look at the value of ex then (with the debugger)

      T 1 Reply Last reply
      0
      • M Michel Godfroid

        Tunisien86 wrote:

        the sqlexception I got :http://yfrog.com/iycaptureawj\[^\]

        Yeah, that one we've already seen. try to get the full exception ON THE PC (see my other reply about this)

        Tunisien86 wrote:

        my emulator doesn't have network connectivity.

        Well, there you have it. No point in testing the others until you can establish that. 1) Is your emulator cradled? 2) do you see the connection in Mobile device center or in ActiveSync?

        T Offline
        T Offline
        Tunisien86
        wrote on last edited by
        #23

        Hi Michel, My emulator is not cradling.When googling,I found this link talking about how to cradle an emulator:http://netcf2.blogspot.com/2005/11/getting-started-using-emulator.html[^] I wanna ask should I use a real PDA?is the emulator enough? Thanks

        M 1 Reply Last reply
        0
        • M Michel Godfroid

          No, that's another exception. It happens because your try block never executed succesfully. put a breakpoint at MessageBox.Show(ex.Message); and look at the value of ex then (with the debugger)

          T Offline
          T Offline
          Tunisien86
          wrote on last edited by
          #24

          Hi Michel, The same appears as i wrote last time,same exception expression thanks

          1 Reply Last reply
          0
          • T Tunisien86

            Hi Michel, My emulator is not cradling.When googling,I found this link talking about how to cradle an emulator:http://netcf2.blogspot.com/2005/11/getting-started-using-emulator.html[^] I wanna ask should I use a real PDA?is the emulator enough? Thanks

            M Offline
            M Offline
            Michel Godfroid
            wrote on last edited by
            #25

            You should cradle it. cradling will give the emulator an IP address. In mobile device center, be sure to select 'DMA' in connection settings. Then do the internet explorer test again.

            T 2 Replies Last reply
            0
            • M Michel Godfroid

              You should cradle it. cradling will give the emulator an IP address. In mobile device center, be sure to select 'DMA' in connection settings. Then do the internet explorer test again.

              T Offline
              T Offline
              Tunisien86
              wrote on last edited by
              #26

              Hi Michel, Sorry for yesterday,I couldn't continue with u because the time work finished and I have no Internet connexion in home.When trying to cradle my emulator,the first step I found is to enable TCP/IP connexion in the emulator.This required to install Virtual PC 2007but got this error while installing:

              Error 1335. The cabinet file 'product.cab' required for this installation is
              corrupt and cannot be used..."

              I tried redownloading VPC and even saving to different disk and still get same error. Any ideas? thanks

              1 Reply Last reply
              0
              • L Lost User

                Tunisien86 wrote:

                In fact,my combobox should contain the result of my select statement,but when running,the system is show an sqlexception and nothing is added to my combobox.

                It's easier to find a problem if you include the message of the exception. In this case it's probably caused by a common error - your tablenames contain illegal characters. You can "fix" it with brackets;

                string sSQL = "SELECT DISTINCT * FROM [D°_urgence]";

                Also note that the change in code assumes that your select-statement is run against an SQL Server instance, one that has access to the *.mdf-file that you want to read from. If this data is stored locally, in an *.sdf file, then you'd indeed need the SqlCe-classes.

                Tunisien86 wrote:

                Or should I take the physical @ as the @ of my computer?

                Ideally, you take the computers' name and the instance name and put it in a configurationfile. Something like "Admin-PC/MySql2005Instance". There might be lots of IP-adresses on a computer, but it usually only has a single name that identifies it in the network. It also communicates easier, imagine yelling "Reboot Skynet and Idefix" in contract to "Reboot One-Nine-Two Doht One-Six-Eight Doht One Doht Zero.. - No Four, I meant Four!" :cool:

                I are Troll :suss:

                T Offline
                T Offline
                Tunisien86
                wrote on last edited by
                #27

                hI Eddy, when trying to cradle my emulator,I can't install the virtual PC 2007 and getting this error:

                Error 1335. The cabinet file 'product.cab' required for this installation is
                corrupt and cannot be used..."

                What can i do?

                L 1 Reply Last reply
                0
                • T Tunisien86

                  hI Eddy, when trying to cradle my emulator,I can't install the virtual PC 2007 and getting this error:

                  Error 1335. The cabinet file 'product.cab' required for this installation is
                  corrupt and cannot be used..."

                  What can i do?

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #28

                  Goodmorning :) Redownload Virtual PC and reinstall it, looks like your setup is corrupt. How is the Sql-query going?

                  I are Troll :suss:

                  T 2 Replies Last reply
                  0
                  • L Lost User

                    Goodmorning :) Redownload Virtual PC and reinstall it, looks like your setup is corrupt. How is the Sql-query going?

                    I are Troll :suss:

                    T Offline
                    T Offline
                    Tunisien86
                    wrote on last edited by
                    #29

                    Hi, I redowload VPC2007 and install it but still the same error.The sql query goes fine.Tha problem is now in the cradling of the emulator. Thanks

                    1 Reply Last reply
                    0
                    • L Lost User

                      Goodmorning :) Redownload Virtual PC and reinstall it, looks like your setup is corrupt. How is the Sql-query going?

                      I are Troll :suss:

                      T Offline
                      T Offline
                      Tunisien86
                      wrote on last edited by
                      #30

                      Hi Thanks I cradled my emulator.The Emulator must be running to be able to cradle it. When should I uncradle my emulator??? When trying to install windows mobile device center,it failed.Should i connect a real device to be able to install this tool??? How can I get the IP number that is used for my device and PC for this TCP/IP connection?????? Thanks a lot for u clarification Marwen Smile

                      L 1 Reply Last reply
                      0
                      • T Tunisien86

                        Hi Thanks I cradled my emulator.The Emulator must be running to be able to cradle it. When should I uncradle my emulator??? When trying to install windows mobile device center,it failed.Should i connect a real device to be able to install this tool??? How can I get the IP number that is used for my device and PC for this TCP/IP connection?????? Thanks a lot for u clarification Marwen Smile

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #31

                        Tunisien86 wrote:

                        When should I uncradle my emulator???

                        That's out of my league; cradling the iPaq was a matter of inserting the USB-cable, never tried it on the emulator.

                        Tunisien86 wrote:

                        When trying to install windows mobile device center,it failed.Should i connect a real device to be able to install this tool???

                        That might be possible; some applications require the real thing and won't work with the emulator.

                        Tunisien86 wrote:

                        How can I get the IP number that is used for my device and PC for this TCP/IP connection??????

                        The IP-adress of the mobile device can be retrieved using this[^] snippet (scroll to the end), the IP-adress of Sql Server should be already known.

                        I are Troll :suss:

                        1 Reply Last reply
                        0
                        • M Michel Godfroid

                          You should cradle it. cradling will give the emulator an IP address. In mobile device center, be sure to select 'DMA' in connection settings. Then do the internet explorer test again.

                          T Offline
                          T Offline
                          Tunisien86
                          wrote on last edited by
                          #32

                          Hi Freinds, Finally I depass the problem of the connexion to server by the DB File's attachment :laugh: . No exception apperas.Still now the problem of the filling of my combobox .I try with sqldataset instead of the sqlreader like this:

                          string sConnection = "Data Source=127.0.0.1,1433;Persist Security Info=True;Initial Catalog=GMAO;User ID=sa;Password=sa";
                          string sSQL = "SELECT com FROM energie; ";
                          SqlConnection conn = new SqlConnection(sConnection);
                          SqlCommand comm = new SqlCommand(sSQL, conn);
                          DataSet ds = new DataSet();
                          SqlCeDataAdapter da = new SqlCeDataAdapter();
                          SqlDataReader dr = null;
                          try
                          {

                          comm.Connection.Open();
                          da.Fill(ds, "SQL Temp Table");
                          foreach(DataRow d in ds.Tables\[0\].Rows)
                          comboBox1.Items.Add(d.ToString());
                          

                          }
                          catch (SqlException ex)
                          {
                          //MessageBox.Show("connexion impossible");
                          MessageBox.Show(ex.Message);
                          return;
                          }

                          dr.Close();
                          comm.Connection.Close();
                          }

                          but nothing is added to my combobox. Thanks in all cases for u collaboration I am really sooooooooooo happy :laugh:

                          1 Reply Last reply
                          0
                          • T Tunisien86

                            Hi, I develop a GMAO csharp smart device application.I try now to connect to my remote database.mdf using TCP/IP protocol.I created a combobox where i want to extract informations from my table using this select statement:

                            "SELECT DISTINCT NObt FROM 4BT ";

                            .For my IPadreess of my computer,I use the ipconfig/all command and I take the

                            IPv4 Address. . . . . . . . . . . : 192.168.1.4(Preferred)

                            My hole code is like this:

                            using System;
                            using System.Linq;
                            using System.Data.SqlServerCe;
                            using System.Collections.Generic;
                            using System.ComponentModel;
                            using System.Data;
                            using System.Data.SqlClient;
                            using System.Drawing;
                            using System.Text;
                            using System.Windows.Forms;

                            namespace ModeDifféré
                            {
                            public partial class Form6 : Form
                            {
                            public Form6()
                            {
                            InitializeComponent();
                            }

                                private void comboBox1\_SelectedIndexChanged(object sender, EventArgs e)
                                {
                            
                                }
                            
                                private void Form6\_Load(object sender, EventArgs e)
                                {
                                    string sConnection = "Data Source=192.168.1.4,1433;Initial Catalog=GMAO;User ID=sa;Password=sa;";
                                    string sSQL = "SELECT DISTINCT NObt FROM 4BT";
                                    SqlCeCommand comm = new SqlCeCommand(sSQL, new SqlCeConnection(sConnection));
                                    SqlCeDataReader dr = null;
                                    try
                                    {
                                        comm.Connection.Open();
                                        dr = comm.ExecuteReader();
                                        while (dr.Read())
                                            comboBox1.Items.Add(dr\[0\]);
                                    }
                                    catch (Exception ex)
                                    {
                                        MessageBox.Show(ex.Message);
                                        return;
                                    }
                                    dr.Close();
                                    comm.Connection.Close();
                                }
                            }
                            

                            }

                            When running,this error appears:

                            Unknown connection option in connection string: initial catalog.

                            As an information,I follow the steps of this link:http://netcf2.blogspot.com/2005/12/accessing-sql-server-express-from.html[^] What is the problem??? Thank u for all u suggestion Regards Marwen :)

                            T Offline
                            T Offline
                            Tunisien86
                            wrote on last edited by
                            #33

                            Hi guys, I depass the problem :laugh: finally of the connection to the server due to the DATABASE FILE's ATTACHMENT. Still now the problem in the filling of my combobox.In fact,no exception appears so connection to server works well.In other hand,nothing is added to my combobox. I try to replace my sqldatareader by sqldataset but still the same thing:

                            private void Form6_Load(object sender, EventArgs e)
                            {

                                    string sConnection = "Data Source=127.0.0.1,1433;Persist Security Info=True;Initial Catalog=GMAO;User ID=sa;Password=sa";
                                    string sSQL = "SELECT com FROM energie; ";
                                    SqlConnection conn = new SqlConnection(sConnection);
                                    SqlCommand comm = new SqlCommand(sSQL, conn);
                                    DataSet ds = new DataSet();
                                    SqlDataAdapter da = new SqlDataAdapter();
                                    SqlDataReader dr = null;
                                    try
                                    {
                                        
                                        comm.Connection.Open();
                                        da.Fill(ds, "SQL Temp Table");
                                        foreach(DataRow d in ds.Tables\[0\].Rows)
                                        comboBox1.Items.Add(d.ToString());
                                    }
                                    catch (SqlException ex)
                                    {
                                        //MessageBox.Show("connexion impossible");
                                        MessageBox.Show(ex.Message);
                                        return;
                                    }
                            
                                    dr.Close();
                                    comm.Connection.Close();
                                }
                            

                            How do I depass that??? Thank u in all cases I am really sooooooo happy :laugh:

                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • World
                            • Users
                            • Groups