Hi, I'm testing unidac with sql server to buy it.
I created a thread.
The Execute function is that:
void __fastcall UpdateThread::Execute()
{
SetName();
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
_uniConnection = new TUniConnection(NULL);
_uniConnection->ProviderName = "SQL Server";
_uniConnection->Database = "RaceManagerDevelopment";
_uniConnection->SpecificOptions->Add("SQL Server.Authentication=auWindows");
_uniConnection->Pooling = true;
_uniConnection->Server = "NB-ALESSANDROM\SQLEXPRESS";
_uniConnection->LoginPrompt = false;
_uniConnection->Connected = true;
CoUninitialize();
}
//---------------------------------------------------------------------------
The thread freezes when execute Connected = true.
It happens also if I pass a working connection to the thread (anotherConnection comes form main thread and works fine)
_uniConnection = new TUniConnection(*anotherConnection);
_uniConnection->Connected = true;
Please let me know what is wrong
Regards
SQL Server and thread
Re: SQL Server and thread
To set the TUniConnection->Server property in your code to NB-ALESSANDROM\SQLEXPRESS , you should use a double-backslash, since a single backslash in a string value will be interpreted by C++Builder as escape sequence. For this, replace the following line in your code:
with this one:
Code: Select all
_uniConnection->Server = "NB-ALESSANDROM\SQLEXPRESS";
Code: Select all
_uniConnection->Server = "NB-ALESSANDROM\\SQLEXPRESS";