Recent

Author Topic: [HELP] Connecting to a SQL - Console Application  (Read 36900 times)

nobodyknowsme

  • Full Member
  • ***
  • Posts: 114
Re: [HELP] Connecting to a SQL - Console Application
« Reply #45 on: December 18, 2014, 11:12:16 am »

It opens and closes straight away like last time now. Its like it doesn't have access. Its connecting I think without any errors but now just selfcloses

minesadorada

  • Sr. Member
  • ****
  • Posts: 453
  • Retired
Re: [HELP] Connecting to a SQL - Console Application
« Reply #46 on: December 18, 2014, 11:14:13 am »

It opens and closes straight away like last time now. Its like it doesn't have access. Its connecting I think without any errors but now just selfcloses
What operating system are you using?  I might be able to do and attach a working example for you.
GPL Apps: Health MonitorRetro Ski Run
OnlinePackageManager Components: LazAutoUpdate, LongTimer, PoweredBy, ScrollText, PlaySound, CryptINI

nobodyknowsme

  • Full Member
  • ***
  • Posts: 114
Re: [HELP] Connecting to a SQL - Console Application
« Reply #47 on: December 18, 2014, 11:23:34 am »
Im using windows 7. AS the console application closes so quickly I wil try and get a photo.

rvk

  • Hero Member
  • *****
  • Posts: 6885
Re: [HELP] Connecting to a SQL - Console Application
« Reply #48 on: December 18, 2014, 11:24:59 am »
It shouldn't be necessary to open 3306 on your router as it is outgoing.

This works perfectly for me:
But you need the libmysql.dll from 5.6 in your .exe directory.
You can take the one from the latest MySQL Workbench installation.

Code: [Select]
program upload2;

uses
  sqldb, mysql56conn;

var
  AConnection: TSQLConnector;

  procedure CreateConnection;
  begin
    AConnection := TSQLConnector.Create(nil);
    AConnection.ConnectorType := 'MySQL 5.6';
    AConnection.Hostname := 'sql5.freemysqlhosting.net';
    AConnection.DatabaseName := 'sql561707';
    AConnection.UserName := 'sql561707';
    AConnection.Password := 'dX3%eP3!';
  end;

begin
  CreateConnection;
  AConnection.Open;
  if Aconnection.Connected then
    begin
    writeln('Successful connect!');
    readln
    end

  else
    writeln('This is not possible, because if the connection failed, an exception should be raised, so this code would not be executed');
  AConnection.Close;
  AConnection.Free;

  readln;

end.
(Result is 'Successful connect!')

nobodyknowsme

  • Full Member
  • ***
  • Posts: 114
Re: [HELP] Connecting to a SQL - Console Application
« Reply #49 on: December 18, 2014, 11:35:09 am »
Okay, It took me a few tries but I got it. Its the libmysql.dll file. I have it installed in the same folder. Do I have a bad dll file or something?


rvk

  • Hero Member
  • *****
  • Posts: 6885
Re: [HELP] Connecting to a SQL - Console Application
« Reply #50 on: December 18, 2014, 11:37:29 am »
If you right-click the libmysql.dll and choose properties and look in details...
what version do you see for that file?

(The one from the latest MySQL Workbench is 5.6.17.0 and works for me)

minesadorada

  • Sr. Member
  • ****
  • Posts: 453
  • Retired
Re: [HELP] Connecting to a SQL - Console Application
« Reply #51 on: December 18, 2014, 11:41:03 am »
Attached: working project (without libmysql.dll)

Put libmysql.dll in the same folder as the project and it should connect.  Tested on Win 7
GPL Apps: Health MonitorRetro Ski Run
OnlinePackageManager Components: LazAutoUpdate, LongTimer, PoweredBy, ScrollText, PlaySound, CryptINI

nobodyknowsme

  • Full Member
  • ***
  • Posts: 114
Re: [HELP] Connecting to a SQL - Console Application
« Reply #52 on: December 18, 2014, 11:41:32 am »
Could you please send me your file as mine doesn't display the version type. Could you please send me your dll file?

minesadorada

  • Sr. Member
  • ****
  • Posts: 453
  • Retired
Re: [HELP] Connecting to a SQL - Console Application
« Reply #53 on: December 18, 2014, 11:44:08 am »
Could you please send me your file as mine doesn't display the version type. Could you please send me your dll file?
https://sourceforge.net/projects/healthdailymonitor/  It's included in the Installer
GPL Apps: Health MonitorRetro Ski Run
OnlinePackageManager Components: LazAutoUpdate, LongTimer, PoweredBy, ScrollText, PlaySound, CryptINI

nobodyknowsme

  • Full Member
  • ***
  • Posts: 114
Re: [HELP] Connecting to a SQL - Console Application
« Reply #54 on: December 18, 2014, 11:49:11 am »
healthdailymonitor? Im sorry whats that? Slightly confused.

rvk

  • Hero Member
  • *****
  • Posts: 6885
Re: [HELP] Connecting to a SQL - Console Application
« Reply #55 on: December 18, 2014, 11:51:06 am »
healthdailymonitor is a program which includes libmysql.dll in its installation,.
So does MySQL Workbench (which is downloadable as a zip so you won't need installation).

But I already PM'd you a link to my version of libmysql.dll 5.6.17.0.

nobodyknowsme

  • Full Member
  • ***
  • Posts: 114
Re: [HELP] Connecting to a SQL - Console Application
« Reply #56 on: December 18, 2014, 11:52:01 am »
okay thank you. I can't download that at the moment as my colleges server wont allow me to access it.

nobodyknowsme

  • Full Member
  • ***
  • Posts: 114
Re: [HELP] Connecting to a SQL - Console Application
« Reply #57 on: December 18, 2014, 11:55:24 am »
healthdailymonitor is a program which includes libmysql.dll in its installation,.
So does MySQL Workbench (which is downloadable as a zip so you won't need installation).

But I already PM'd you a link to my version of libmysql.dll 5.6.17.0.

I have downloaded your DLL file and put it in the directory. I don't get that error anymore however it now breaks at AConnection.Open;

Here is my code, and a screen shot showing the latest dll file. Thank you so much for help BTW.

 Also would it matter the type of OS? I am running windows 7. I have your DLL file and your code. WHy doesn't it work. DO I need to do something with the file or something?! Could you dropbox me your whole folder with this in at all?

Thanks again
« Last Edit: December 18, 2014, 11:58:46 am by nobodyknowsme »

rvk

  • Hero Member
  • *****
  • Posts: 6885
Re: [HELP] Connecting to a SQL - Console Application
« Reply #58 on: December 18, 2014, 12:01:17 pm »
okay thank you. I can't download that at the moment as my colleges server wont allow me to access it.
I'm beginning to think your college blocks direct access to the internet (as minesadorada already asked) and only allows port 80 activity.
So maybe port 3306 is blocked by the Firewall of your college.

Could you download MySQL Workbench and install it. It's a MySQL manager local on your machine which can connect to a remote MySQL-database. You can create and fill in tables etc.

http://dev.mysql.com/downloads/workbench/
Choose download (Windows (x86, 32-bit), ZIP Archive). (After unzipping you can run it directly)
You don't have to register to download... In the next screen you can just choose "No thanks, just start my download." at the bottom.
« Last Edit: December 18, 2014, 12:19:00 pm by rvk »

minesadorada

  • Sr. Member
  • ****
  • Posts: 453
  • Retired
Re: [HELP] Connecting to a SQL - Console Application
« Reply #59 on: December 18, 2014, 12:23:53 pm »
I have downloaded your DLL file and put it in the directory. I don't get that error anymore however it now breaks at AConnection.Open;
Download and compile and run the example app I posted. Make sure the downloaded mysqllib.dll is in the same folder as the compiled app.

If it doesn't connect successfully on your system, then you have either a port problem (as rvk said) or an AV app that is blocking it.
GPL Apps: Health MonitorRetro Ski Run
OnlinePackageManager Components: LazAutoUpdate, LongTimer, PoweredBy, ScrollText, PlaySound, CryptINI

 

TinyPortal © 2005-2018