Page 1 of 2
Cannot connect to DB
Posted: Wed 03 Apr 2013 12:57
by Bobster
DAC 7.6.12; Delphi XE2, Update 4, HotFix 1; Windows 7.6.1, Build 7601, SP1.
I can connect from the IDE, but using the same params and whether or not LoginPrompt is True, when I try to connect at runtime I get:
'Cannot create TCP/IP socket: The requested service provider could not be loaded or initialized. Socket error code 10106.'
Please tell me what I am missing. Thanks.
Re: Cannot connect to DB
Posted: Fri 05 Apr 2013 10:46
by DemetrionQ
Hello.
Detailed information about the "WSAEPROVIDERFAILEDINIT 10106" error can be read in MSDN.
The work of your IDE is probably blocked by your Firewall or other similar programs (such as Anti-Malware). Please check your Firewall settings. Also, try adding your IDE to the Firewall exclusion list.
Re: Cannot connect to DB
Posted: Sat 06 Apr 2013 16:14
by Bobster
Thanks for your response. I tried your suggestions re firewall, including dropping the firewall and suspending real-time protection on my AV package: same result. I have spent the last day or so since your response researching this further without an MSDN subscription. I tried starting Winsock using WSAStartup; completes successfully. I cannot get control back using try/except around the Connect so I cannot get any further details on the error. Program runs fine from the executable, just not from the debugger. I could use Embedded during development and then switch but I am not entirely comfortable with that. I will limp along until I limp to the finish line or I come across a solution. If you have any other insights I would be grateful for them. Thanks again.
Re: Cannot connect to DB
Posted: Mon 08 Apr 2013 17:34
by DemetrionQ
Hello.
Please run the following code, and check if the error occurs:
Code: Select all
#include <WinSock.h>
...
{
Integer Sd, Res;
WSADATA WsaData;
String LastError;
Res = WSAStartup(0x0202, &WsaData);
if(Res != 0){
TVarRec vr[] = {Res};
LastError = Sysutils::Format("WSAStartup failed'#$D#$A'Socket Error Code: %d", vr,1);
throw Exception(LastError);
}
Sd = socket(AF_INET, SOCK_STREAM, 0);
if(Sd == SOCKET_ERROR){
TVarRec vr[] = {SysErrorMessage(WSAGetLastError()), WSAGetLastError(), WSAGetLastError()};
LastError = Sysutils::Format("Cannot create TCP/IP socket:'#$D#$A'%s.'#$D#$A'Socket Error Code: %d($%X)", vr, 3);
throw Exception(LastError);
}
}
Re: Cannot connect to DB
Posted: Mon 08 Apr 2013 23:26
by Bobster
I have to admit that my C++ experience is limited and I don't even have a C++ compiler installed, although if I did I think I could do this. Could you send me Delphi code or an executable? I hate to be a pest but that's where I'm at. Thank you.
Bob
Re: Cannot connect to DB
Posted: Tue 09 Apr 2013 07:47
by DemetrionQ
Hello.
I am sorry, it was my mistake.
Please run the following code, and check if the error occurs:
Code: Select all
uses WinSock;
...
var
Sd, Res: integer;
LastError : string;
WsaData: TWSAData;
begin
Res := WSAStartup($0202, WsaData);
if Res <> 0 then begin
LastError := Format('WSAStartup failed'#$D#$A'Socket Error Code: %d', [Res]);
raise Exception.Create(LastError);
end;
Sd := socket(AF_INET, SOCK_STREAM, 0);
if Sd = SOCKET_ERROR then begin
LastError := Format('Cannot create TCP/IP socket:'#$D#$A'%s.'#$D#$A'Socket Error Code: %d($%X)', [SysErrorMessage(WSAGetLastError), WSAGetLastError, WSAGetLastError]);
raise Exception.Create(LastError);
end;
end;
Re: Cannot connect to DB
Posted: Tue 09 Apr 2013 14:10
by Bobster
Thanks much. It runs without error.
Re: Cannot connect to DB
Posted: Thu 11 Apr 2013 12:08
by DemetrionQ
Hello.
Please try the following:
- uninstall MyDAC;
- delete all *dac*.bpl , *crcontrols*.bpl files from your computer;
- search all DAC units on your computer, such as MemData.dcu, MemDS.dcu, DBAccess.dcu, MyClasses.dcu, CRGrid.dcu etc., and delete them.
- install MyDAC.
MyDAC distribution includes a demo project located in the "MyDacDemo" folder in Demos of MyDAC. Check if the problem can be reproduced on this demo project.
Re: Cannot connect to DB
Posted: Mon 15 Apr 2013 15:54
by Bobster
I ran demo and it connected successfully. Following is the code I use for my connect, which I would normally run with LoginPrompt := False:
procedure ConnectToDB(dbc: TMyConnection);
begin
with dbc do begin
Database := DBNAME;
Options.Embedded := False;
Options.Direct := True;
Options.NullForZeroDelphiDate := True;
Server := 'localhost';
Port := 3306;
Username := currentun;
Password := GetPWForLogin(SITE_PW);
LoginPrompt := True;
Connect;
end;
end;
I just noticed for the first time that this code was not even being executed. I turned off optimization and now it is executing but makes no difference. I can change whatever I want in that proc and the dialog remains unchanged. I have found discussion in the forum that tells me this is "normal". I don't understand why but before I uninstall, etc. I will write a custom dialog. I appreciate your support.
Bob
Re: Cannot connect to DB
Posted: Wed 17 Apr 2013 13:24
by DemetrionQ
Hello.
By default, the standard connection dialog displays data of the last successful connection saved in the registry. If you need to disable this specificity, set the TMyConnectDialog.StoreLogInfo property to False, like this:
Code: Select all
MyConnectDialog1.StoreLogInfo := False;
If you want to create a custom connection dialog, you can use the ConnectDialog demo of MyDAC demo project.
Re: Cannot connect to DB
Posted: Wed 17 Apr 2013 15:26
by Bobster
The StoreLogInfo property is not published and I don't have the source code for DBAccess. Am I out of luck?
Re: Cannot connect to DB
Posted: Fri 19 Apr 2013 10:53
by DemetrionQ
Hello.
The TMyConnectDialog.StoreLogInfo property is published. This is a property of the TMyConnectDialog class, please make sure that you are looking for it in this class.
Re: Cannot connect to DB
Posted: Fri 19 Apr 2013 14:18
by Bobster
Here is what I am trying:
procedure ConnectToDB(dbc: TMyConnection);
begin
with dbc do begin
TMyConnectDialog.StoreLogInfo := False;
.
.
.
[DCC Error] DBOps.pas(242): E2233 Property 'StoreLogInfo' inaccessible here
Re: Cannot connect to DB
Posted: Sun 21 Apr 2013 15:33
by Bobster
Demetrion,
Please ignore my last post. The light finally dawned. I created an instance of TMyConnectDialog, hooked things up, and all is well. That's the good news. The bad news is that I still get the socket exception and can't connect. I will take your advice and uninstall, delete files, and start from scratch. Thanks for your patience.
Bob
Re: Cannot connect to DB
Posted: Thu 25 Apr 2013 00:02
by Bobster
Demetrion,
This is my version of mea culpa. I solved the problem in the following way:
After many trials/errors, reinstall Devart, upgrade MySQL to version 5.6, scratching head, cussing and worse, I looked at the Options for my project. I discovered under the Debugger/Environment Block I had overridden the PATH variable by adding a folder in which was located a version of libmysqld.dll dated 3/22/2012. I did this eons ago for now-unknown reasons when I was using the embedded server. I eliminated the override and voila, success. I wish I understood all I know about this stuff.
Thanks again for your help. You steered me in some directions that I might not have discovered on my own; e.g. MyDacDemo. I am off to start coding again.
Bob