Note that there are some explanatory texts on larger screens.

plurals
  1. POMysqlCommand switching connection unexpectedtly
    primarykey
    data
    text
    <p>I have a little problem with my MysqlConnection objets. I have those two connection strings in my app.config : </p> <pre><code>&lt;connectionStrings&gt; &lt;add name="bdpvcLocalhost" connectionString="Persist Security Info=False;server=localhost;Uid=root;Password=***;database=bdpvc" providerName="Mysql.Data.MySqlClient"/&gt; &lt;add name="bdpvcProduction" connectionString="server=pvcserver.pvcservprod.local;user id=pvc_app;Pwd=***;database=bdpvc" providerName="Mysql.Data.MySqlClient"/&gt; &lt;/connectionStrings&gt; </code></pre> <p>The first connection is for a local test database, the second one is for the real production database. Since i am still early in the developpement, I use my local database. I then use the following code (I cut some of the Parameters definition cause there is really a lot)</p> <pre><code>using (MySqlConnection connection = new MySqlConnection(_connectionString)) { connection.Open(); using (MySqlTransaction transaction = connection.BeginTransaction()) { const string sequenceQuery = "INSERT INTO sequence " + "(No_Sequence, No_Client, No_Produit, No_Version_Produit, " + " No_Soumission, No_Commande, No_Reference, Date_Livraison, " + "Date_Commande, Date_Soumission, Quantite, Status, Contact, " + "Notes, No_Production_Ancien, Erreur_Production, No_Fichier_Log, " + "No_Utilisateur, Date_Enregistrement, Extension_Fichier_Fax, Uuid) " + "VALUES(?No_Sequence, ?No_Client, ?No_Produit, ?No_Version_Produit, " + "?No_Soumission, ?No_Commande, ?No_Reference, ?Date_Livraison, ?Date_Commande, " + "?Date_Soumission, ?Quantite, ?Status, ?Contact, ?Notes, ?No_Production_Ancien, " + "?Erreur_Production, ?No_Fichier_Log, ?No_Utilisateur, ?Date_Enregistrement, " + "?Extension_Fichier_Fax, ?Uuid)"; const string selectSequenceNoQuery = "SELECT MAX(No_Sequence) AS Valeur_No_Increment FROM sequence"; const string updateSequenceNoQuery = "UPDATE tables SET Valeur_No_Increment = ?Valeur_No_Increment WHERE Nom_Tables = 'sequence'"; int currentIncrement = 0; MySqlCommand selectNoSequenceCommand = new MySqlCommand(selectSequenceNoQuery, connection, transaction); MySqlCommand updateNoSequenceCommand = new MySqlCommand(updateSequenceNoQuery, connection, transaction); MySqlCommand insertSequenceCommand = new MySqlCommand(sequenceQuery, connection, transaction); //------------------------------ //This query execute perfectly! currentIncrement = Int32.Parse(selectNoSequenceCommand.ExecuteScalar().ToString()); insertSequenceCommand.Parameters.Add("?No_Sequence", MySqlDbType.String); //Lots and lot of parameters definition foreach (Sequence sequence in _sequences) { currentIncrement++; sequence.No_Sequence = currentIncrement.ToString(); insertSequenceCommand.Parameters["?No_Sequence"].Value = sequence.No_Sequence; //Lots and lots of value assignement //--------------------------------- //But this one doesn't use the right user! insertSequenceCommand.ExecuteNonQuery(); Console.WriteLine("Inserted new sequence with Uuid " + sequence.Uuid + " and increment " + sequence.No_Sequence); } updateNoSequenceCommand.Parameters.AddWithValue("?Valeur_No_Increment", currentIncrement); updateNoSequenceCommand.ExecuteNonQuery(); transaction.Commit(); } } </code></pre> <p>The first query execute just fine. However, the second query isn't able to execute, because "the user <code>pvc_app</code> doesn't exists". <em>But I am connecting to my local database as root! And never in my code do I switch connection string!</em> I tried deleting the second connection string in app.config, but it kept trying to connect as <code>pvc_app</code>. I rebuild the application multiple time, rebooted my computer and even uninstalled/reinstalled the ADO.NET connector, but it kept trying to connect as pvc_app! Am I doing something wrong here?</p> <p>Now, where is located this mysterious "connection string cache" so I can kill it with my bare hand? Cause it's really making my life a misery right now.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload