Note that there are some explanatory texts on larger screens.

plurals
  1. POMySQL connection prompts for password even though this is in the connection string
    primarykey
    data
    text
    <p>This one looks like a bizarre one.</p> <p>I have a Pascal unit that connects to a MySQL database</p> <pre><code>unit u_MySQLConnection; interface uses ADODB, AnsiStrings, Generics.Collections, SysUtils, DB ; type TMySQLConnection = class strict private mysqlCon : TADOConnection; public function Connect:boolean; destructor Destroy; end; var MySQLConnection : TMySQLConnection; implementation function TMySQLConnection.Connect:boolean; var success : boolean; begin success := true; try if NOT (mysqlCon = nil) then mysqlCon.Destroy; mysqlCon := TADOConnection.Create(nil); mysqlCon.ConnectionString := 'DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost; DATABASE=database; UID=root; PASSWORD=password;OPTION=3;'; except success := false; end; Result := success; end; destructor TMySQLConnection.Destroy; begin FreeAndNil(mysqlCon); inherited; end; end. </code></pre> <p>And when I try to connect</p> <pre><code>MySQLConnection := TMySQLConnection.Create; try MySQLConnection.Connect; finally MySQLConnection.Destroy; end; </code></pre> <p>I get a password prompt dialog box appearing, even though the password is already in the connection string. If I enter the username and password into this prompt, everything else works fine.</p> <p>Things get a little bit more strange here:</p> <p>When i move the database connection command into the main .dpr file as shown</p> <pre><code>program DieselBatch; uses Vcl.Forms, u_MySQLConnection in '..\src\u_MySQLConnection.pas' (*, frm_About in '..\src\frm_About.pas' {frmAbout}, frm_AnalystDetails in '..\src\frm_AnalystDetails.pas' {frmAnalystDetails}, frm_Batch in '..\src\frm_Batch.pas' {frmBatch}, frm_ConfirmResultsChanged in '..\src\frm_ConfirmResultsChanged.pas' {frmConfirmResultsChanged}, frm_DebugSample in '..\src\frm_DebugSample.pas' {frmDebugSample}, frm_FlashManualEntry in '..\src\frm_FlashManualEntry.pas' {frmFlashEntry}, frm_Main in '..\src\frm_Main.pas' {frmMain}, frm_SampleComment in '..\src\frm_SampleComment.pas' {frmSampleComment}, frm_SelectAnalystForResult in '..\src\frm_SelectAnalystForResult.pas' {frmSelectAnalystForResult}, u_Data in '..\src\u_Data.pas', u_MicroCheck in '..\src\u_MicroCheck.pas', u_Undo in '..\src\u_Undo.pas' *) ; {$R *.res} var MySQLConnection : TMySQLConnection; begin MySQLConnection := TMySQLConnection.Create; try MySQLConnection.Connect; finally MySQLConnection.Destroy; end; </code></pre> <p>Then the password prompt does not appear, as long as those units are commented out.</p> <p>When I uncomment the above units again, the problem reappears.</p> <p>Some of those units do use ADODB and DB but I can't see how the mere presence of the units should affect the behavour of the MySQLConnection unit .... </p>
    singulars
    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.
 

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