BCB2010 DBX 的問題
裝上了BCB2010 UP4 UP5
生成一個 SQLConnection , 正常連接,可是如下簡單代碼,發生故障:程序無法退出。即關閉程序後,程序依然駐留不能退出。如果有裝 2010的,請試一下,不知何原因,如何解決。
#include <vcl.h>#pragma hdrstop#include "Unit1.h"#include <SqlExpr.hpp>//---------------------------------------#pragma package(smart_init)#pragma resource "*.dfm"TForm1 *Form1;TSQLConnection *SQLConnection = NULL ;//---------------------------------------__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner){ SQLConnection = new TSQLConnection(NULL); SQLConnection->ConnectionName = "MSSQLConnection"; SQLConnection->DriverName = "MSSQL"; SQLConnection->GetDriverFunc = "getSQLDriverMSSQL"; SQLConnection->LibraryName = "dbxmss.dll" ; SQLConnection->VendorLib = "sqlncli10.dll"; SQLConnection->LoadParamsOnConnect = false; SQLConnection->KeepConnection = true ; SQLConnection->LoginPrompt = false; SQLConnection->Params->Text = "DriverName=MSSQL" "\nHostName=" "\nDataBase=MyDBS" "\nBlobSize=-1" "\nUser_Name=" "\nPassword=" "\nErrorResourceFile=" "\nLocaleCode=0000" "\nMSSQL TransIsolation=ReadCommited" "\nOS Authentication=True" "\nPrepare SQL=False" "\nMars_Connection=False" "\nSchemaOverride=sa.dbo" "\n"; SQLConnection->Connected = true ; //如果將這名注釋掉,程序可以正常退出。}//---------------------------------------__fastcall TForm1::~TForm1(){ delete SQLConnection ;}
还有,如果没有特别原因建议建立一个数据模块,把需要用到的对象直接在设计时放在数据模块上面,以后可以分到多线程里处理,像你现在这样new 来new去的,还不如直接设计时放在窗体上。