BCB2010 DBX 的問題

勉励前行 2010-01-05 09:11:15
裝上了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 ;
}
...全文
219 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
土著巫师 2010-02-10
  • 打赏
  • 举报
回复
  在窗体的构造函数里直接SQLConnection->Connected = true;从来没这么用过,建议在FormShow事件里PostMessage一个消息给本窗体,异步起动连接过程;另外不能直接delete SQLConnection;了事,要先SQLConnection->Connected = false;

  还有,如果没有特别原因建议建立一个数据模块,把需要用到的对象直接在设计时放在数据模块上面,以后可以分到多线程里处理,像你现在这样new 来new去的,还不如直接设计时放在窗体上。
PointertoPointer 2010-02-05
  • 打赏
  • 举报
回复
200分啊,不会也要进来顶顶
勉励前行 2010-01-23
  • 打赏
  • 举报
回复
因为是动态连接,不知道使用的是哪种数据库,按说将所有支持的数据库都静态链接上去也不为过。不过如果采用态连接的方式,应该是实际使用哪种数据库,就带上对应的DLL即可。

在B2007的时候,动态连接时不用#include所有的头文件的,只要配置正确,就能正常使用。在B2010中,也可以看到不#include对应头文件,也能使用,但不能正常退出,就郁闷了。

#include对应头文件,只是一种无奈的解决方法。不得不将所有支持的数据库类型均静态连接入程序中。动态配置带来的好处大打折扣。

我是从B2007升级上来的代码中发现这个问题的。
柯本 2010-01-22
  • 打赏
  • 举报
回复
我的TSQLConnection 只要在界面上加入,如果是连接SQLSERVER就会自动加入
#include <DBXMsSQL.hpp>
#include <SqlExpr.hpp>
如果是连接oracle就会自动加入
#include <DBXOracle.hpp>
你因为是动态创建的,所以也要手工加入相应的头文件,否则即使能编译运行也可能出错
这在bcb中是常见的
柯本 2010-01-22
  • 打赏
  • 举报
回复
单位里没环境,回家后试,先mark一下
如果加个头文件#include <DBXMsSQL.hpp>就能解决,也没什么大问题,EHLIB控件在连接数据库时也要针对不同的数据库用不同头文件,而且可同时加上几个以联多个数据库
gallardo 2010-01-21
  • 打赏
  • 举报
回复
问题应该出在 delete SQLConnection; 上,建议关闭连接后销毁,或者指定其父对象,由父对象负责它的销毁
TripH0101 2010-01-20
  • 打赏
  • 举报
回复
木用2010, 帮顶.
勉励前行 2010-01-07
  • 打赏
  • 举报
回复
今天再試,發現非要加上 #include <DBXMsSQL.hpp> 這個頭文件,才能正常退出。
不加上,也可正常編譯運行,正常連接使用,但是不能正常退出。

加上後得重新 Build 才行。哪位給出動態連接的代碼,即不用#include <DBXMsSQL.hpp>也可正常使用正常退出,加上這個頭文件,那不是把程序鎖死在 SQL Server 上了嗎。

如何正常切換鏈接到不同的數據庫MSSQL MYSQL ORACLE ? 總不能把所有的頭文件都加上吧。
我不懂电脑 2010-01-07
  • 打赏
  • 举报
回复
关闭一下SQLConnection看看
勉励前行 2010-01-06
  • 打赏
  • 举报
回复
試了下用拖拉控件的方式,只放一個 TSQLConnection 在Form上 , 設定適合參數,只要 SQLConnection->Connected = true ; 結果同樣無法正常退出。要用任務管理器強行中止才行。
ydlchina 2010-01-06
  • 打赏
  • 举报
回复
还没用到这么高的版本
hemiya 2010-01-06
  • 打赏
  • 举报
回复
没SQL Server,在盒子上看过相似的问题,建议安最新版的SQL Server.
DBX连mssql和mysql数据库的错误,与数据库的版本有一定关系.
一般都是安装相对应的数据库.好方法不清楚.
这两个数据库我都不用.
周药师 2010-01-05
  • 打赏
  • 举报
回复
SQLServer2008 要裝.net 3.5
由於XX原因 我的電腦不能安裝.net3.5
不能幫和樓主一起測試
只能幫頂
CACACACACA 2010-01-05
  • 打赏
  • 举报
回复
木用2010, 帮顶.
勉励前行 2010-01-05
  • 打赏
  • 举报
回复
"\nHostName="
"\nDataBase=MyDBS"
這兩句依據自己的實際情況,修改一下。我測試時連接的是本機的 SQL Server 2005 開發版,並裝上SQLServer2008的sqlncli.msi
FastReport.v4.9.81 for.Delphi.BCB.Full.Source企业版含ClientServer中文修正版 delphi2010中文完美支持。 D2010安装必读 delphi2010使用者安装时,请将res\frccD14.exe更名名为frcc.exe frccD14.exe 是专门的delphi2010编码器。其他delphi版本,请使用frcc.exe FASTREPORT® 4.9 VCL - report generator for Delphi CURRENT VERSION Build: 4.9.81 Date: 05/31/10 FastReport®4 VCL is an add-on component that allows your application to generate reports quickly and efficiently. FastReport® provides all the necessary tools to develop reports, including a visual report designer, a reporting core, and a preview window. It can be used in the CodeGear (exBorland) Delphi 4-2010, CodeGear C++Builder 6-2010 and CodeGear RAD Studio environments What's new in the FastReport 4 Report Designer: new XP-style interface the "Data" tab with all report datasets ability to draw diagrams in the "Data" tab code completion (Ctrl+Space) breakpoints watches report templates local guidelines (appears when you move or resize an object) ability to work in non-modal mode, mdi child mode Report Preview: thumbnails Print: split a big page to several small pages print several small pages on one big print a page on a specified sheet (with scale) duplex handling from print dialogue print copy name on each printed copy (for example, "First copy", "Second copy") Report Core: "endless page" mode images handling, increased speed the "Reset page numbers" mode for groups reports crypting (Rijndael algorithm) report inheritance (both file-based and dfm-based) drill-down groups frxGlobalVariables object "cross-tab" object enhancements: improved cells appearance cross elements visible in the designer fill corner (ShowCorner property) side-by-side crosstabs (NextCross property) join cells with the same value (JoinEqualCells property) join the same string values in a cell (AllowDuplicates property) ability to put an external object inside cross-tab AddWidth, AddHeight properties to increase width&height of the cell AutoSize property, abilit
全网第一家 FastReport.v4.8.36 for.Delphi.BCB.Full.Source 最新版 CURRENT VERSION Build: 4.8.36 Date: 11/22/09 http://fast-report.com/en/products/report-for-delphi-fastreport-4-feature-matrix.html FastReport Studio 4.8 released! + added ability to split big bands(biggest than page height) by default + added ability to use keeping(KeepTogether/KeepChild/KeepHeader) in multi-column report + added BDE engine + added DBX engine + added confirmation reading for TfrxMailExport + added new enumerations drDontEditReportScript and drDontEditInternalDatasets to TfrxDesignerRestriction + added new TfrxDesignerRestriction: drDontEditReportScript and drDontEditInternalDatasets + added PrnOutFileName property to printer options + added RTF 4.1 support for TfrxRichText object + added TfrxDesigner.MemoParentFont property + added TfrxGroupHeader.ShowChildIfDrillDown property + added TfrxPrintOptions.PrnOutFileName property to set ability to print to file + added TfrxReportOptions.HiddenPassword property to set password silently from code + added TimeOut field to TfrxMailExport form + added checksum calculating for 2 5 interleaved barcode * changed PDF export: added full unicode support, improved performance, decreased memory requirements - changed inheritance mechanism, correct inherits of linked objects (fixups) - fixed "Page" and "Line" variables inside vertical bands - fixed ActiveForm ActiveX object - fixed bug in multi-column page when band overlap stretched PageHeader - fixed bug when cross tab cut the text in corner, when corner height greater than column height - fixed bug when designer place function in commented text block - fixed bug when designer shows commented functions in object inspector - fixed bug when engine delete first space from text in split Memo - fixed bug when Engine try to split non-stretcheable view and gone to endless loop - fixed bug when group doesn't fit on the whole page - fixed bug with displacement of subreport when use PrintOnParent property in s

1,178

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder 数据库及相关技术
社区管理员
  • 数据库及相关技术社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧