IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Windows Mobile .NET Discussion :

[SQL server] Connection remote database


Sujet :

Windows Mobile .NET

  1. #1
    Membre expérimenté

    Homme Profil pro
    Senior Développeur JEE
    Inscrit en
    Avril 2002
    Messages
    795
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Belgique

    Informations professionnelles :
    Activité : Senior Développeur JEE
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2002
    Messages : 795
    Points : 1 660
    Points
    1 660
    Par défaut [SQL server] Connection remote database
    Bonjour,

    J'ai un petit soucis, je n'arrive pas à effectuer une simple connexion entre une application C# depuis mon pda vers une base sql server.

    Tout ce qu'il me retourne est un SQLException.

    Je pense que mon problème vient de la connect string.

    La voici:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    String remoteConnectString = @"Data Source=" + remoteDatasource + ";Initial Catalog=" + remoteDatabase + ";Integrated Security=SSPI;User Id=" + remoteUser + ";Password=" + remotePassword;
    Le problème est que la base de donnée sql server ne se trouve pas dans un domaine.

    Est-il possible d'effectuer une connection vers une base sql sans que celle-ci se trouve dans un domaine??

    Merci d'avance pour vos réponses.

  2. #2
    Membre expérimenté

    Homme Profil pro
    Senior Développeur JEE
    Inscrit en
    Avril 2002
    Messages
    795
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Belgique

    Informations professionnelles :
    Activité : Senior Développeur JEE
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2002
    Messages : 795
    Points : 1 660
    Points
    1 660
    Par défaut
    En fait la connexion fonctionne.

    Maintenant ce qui ne marche pas c'est le "Command.ExecuteReader".

    Voici la méthode complète:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    public void testSynchronize()
            {
                getProperties();
                //String remoteConnectString = @"Data Source=" + remoteDatasource + ";Initial Catalog=" + remoteDatabase + ";Integrated Security=SSPI;User Id=" + remoteUser + ";Password=" + remotePassword;
                String remoteConnectString = @"Data Source=158.166.3.15;Initial Catalog=PDA_IMPORT;User Id=NIS_PDA_USER;Password=intrasoft08";
     
                SqlCeConnection localConnection = CreateConnection();
     
                SqlConnection remoteConnection = new SqlConnection(remoteConnectString);
                MessageBox.Show(remoteConnection.WorkstationId.ToString());
                MessageBox.Show("STATUT DE LA CONNEXION : " + remoteConnection.State.ToString());
                MessageBox.Show(remoteConnection.ConnectionString.ToString());
                MessageBox.Show(remoteConnection.Database.ToString());
                MessageBox.Show(remoteConnection.DataSource.ToString());
                remoteConnection.Open();
                MessageBox.Show("STATUT DE LA CONNEXION : " + remoteConnection.State.ToString());
                String sql = "select count(*) from PDA_IMPORT.dbo.taches";
                SqlCommand command = new SqlCommand(sql, remoteConnection);
                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    MessageBox.Show(""+reader.GetInt32(0));
                }
                reader.Close();
                command.Dispose();
                remoteConnection.Close();
            }
    Le statut de la connexion est sur OPEN.

    Et l'exception est catchée à la ligne:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    SqlDataReader reader = command.ExecuteReader();
    Et voici la trace de l'exception:

    System.Data.SqlClient.SqlException was unhandled
    Message="SqlException"
    Class=16
    LineNumber=1
    Number=208
    Procedure=""
    Server="APPLNX2"
    Source=".Net SqlClient Data Provider"
    State=1
    StackTrace:
    à System.Data.SqlClient.SqlConnection.OnError(SqlException exception, TdsParserState state)
    à System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, TdsParserState state)
    à System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
    à System.Data.SqlClient.TdsParser.Run(RunBehavior run, SqlCommand cmdHandler, SqlDataReader dataStream)
    à System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
    à System.Data.SqlClient.SqlDataReader.get_MetaData()
    à System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
    à System.Data.SqlClient.SqlCommand.ExecuteReader()
    à NIS_2008_Sync_Data.SyncNisData.testSynchronize()
    à NIS_2008_Sync_Data.SyncDataForm.buttonImport_Click(Object sender, EventArgs e)
    à System.Windows.Forms.Control.OnClick(EventArgs e)
    à System.Windows.Forms.Button.OnClick(EventArgs e)
    à System.Windows.Forms.ButtonBase.WnProc(WM wm, Int32 wParam, Int32 lParam)
    à System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam)
    à Microsoft.AGL.Forms.EVL.EnterMainLoop(IntPtr hwnMain)
    à System.Windows.Forms.Application.Run(Form fm)
    à NIS_2008_Sync_Data.LaunchSyncDataForm.Main()
    Merci d'avance pour votre aide.

  3. #3
    Membre émérite
    Avatar de laedit
    Homme Profil pro
    Consultant études et développement
    Inscrit en
    Décembre 2006
    Messages
    1 344
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Consultant études et développement
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Décembre 2006
    Messages : 1 344
    Points : 2 265
    Points
    2 265
    Par défaut
    ça m'a tout l'air d'être la requête qui ne marche pas.
    L'as tu testée sur la base directement ?
    Et quel est le message exact de l'exception ?

  4. #4
    Membre expérimenté

    Homme Profil pro
    Senior Développeur JEE
    Inscrit en
    Avril 2002
    Messages
    795
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Belgique

    Informations professionnelles :
    Activité : Senior Développeur JEE
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2002
    Messages : 795
    Points : 1 660
    Points
    1 660
    Par défaut
    Ben justement le message exact de l'exception c'est:

    SqlException
    et rien d'autre.

    L'exception ne me dit pas si l'objet existe sur la base cible, ou que sais-je.

    Rien, Nada.

  5. #5
    Membre expérimenté

    Homme Profil pro
    Senior Développeur JEE
    Inscrit en
    Avril 2002
    Messages
    795
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Belgique

    Informations professionnelles :
    Activité : Senior Développeur JEE
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2002
    Messages : 795
    Points : 1 660
    Points
    1 660
    Par défaut
    Ha oui en effet, quand je catche l'exception, il me dit invalid object name.

    Bizarre, car quand j'utilise RDA, cela marche sans problème les méthodes push et pull et mentionnant cette table.

  6. #6
    Membre expérimenté

    Homme Profil pro
    Senior Développeur JEE
    Inscrit en
    Avril 2002
    Messages
    795
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Belgique

    Informations professionnelles :
    Activité : Senior Développeur JEE
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2002
    Messages : 795
    Points : 1 660
    Points
    1 660
    Par défaut


    ok cela marche.

    Enfin presque.

    Maintenant il me retourne

    Invalid attempt to read when no data is present.
    Alors que la table contient plus de 200 lignes.

  7. #7
    Membre émérite
    Avatar de laedit
    Homme Profil pro
    Consultant études et développement
    Inscrit en
    Décembre 2006
    Messages
    1 344
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Consultant études et développement
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Décembre 2006
    Messages : 1 344
    Points : 2 265
    Points
    2 265
    Par défaut
    Ah... Là forcément, c'est bizarre

    Ta requête fonctionne bien quand tu la teste directement sur la base ?

  8. #8
    Membre expérimenté

    Homme Profil pro
    Senior Développeur JEE
    Inscrit en
    Avril 2002
    Messages
    795
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Belgique

    Informations professionnelles :
    Activité : Senior Développeur JEE
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2002
    Messages : 795
    Points : 1 660
    Points
    1 660
    Par défaut
    Je comprends plus rien.

    Si je fait

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
     select count(*) from tache
    Il me retourne 306.

    Si je fait

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
     select tache_id from tache
    il me dit
    Invalid attempt to read when no data is present.
    Alors que tache_id c'est la primary key.

  9. #9
    Membre émérite
    Avatar de laedit
    Homme Profil pro
    Consultant études et développement
    Inscrit en
    Décembre 2006
    Messages
    1 344
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Consultant études et développement
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Décembre 2006
    Messages : 1 344
    Points : 2 265
    Points
    2 265
    Par défaut
    O_o

    alors là, c'est bizarre... Et pas moyen de savoir si ça provient de la base ou des objets .net ?

  10. #10
    Membre expérimenté

    Homme Profil pro
    Senior Développeur JEE
    Inscrit en
    Avril 2002
    Messages
    795
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Belgique

    Informations professionnelles :
    Activité : Senior Développeur JEE
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2002
    Messages : 795
    Points : 1 660
    Points
    1 660
    Par défaut


    Je viens de refaire exactement la même chose ici.

    Et maintenant ça marche.

    Bon ben problème résolu.

    Merci pour ton aide.

  11. #11
    Membre émérite
    Avatar de laedit
    Homme Profil pro
    Consultant études et développement
    Inscrit en
    Décembre 2006
    Messages
    1 344
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Consultant études et développement
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Décembre 2006
    Messages : 1 344
    Points : 2 265
    Points
    2 265
    Par défaut
    Ben vu ce que j'ai fait hein

    Heureux que tu sois arrivé à résoudre le problème !

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. SQL Server 2008 - Audit database specification
    Par Ptit_Dje dans le forum Administration
    Réponses: 3
    Dernier message: 15/10/2010, 10h20
  2. Réponses: 3
    Dernier message: 04/03/2010, 15h38
  3. Réponses: 0
    Dernier message: 31/07/2007, 09h43
  4. Réponses: 1
    Dernier message: 16/05/2007, 15h54
  5. [JDBC][SQL Server]Connection Pooling
    Par WE dans le forum JDBC
    Réponses: 4
    Dernier message: 14/03/2006, 09h15

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo