重奖!!!!!!关于在dll中使用ado的问题

抬头看路 2002-07-19 11:56:31
环境:win2k
bcb6
sybase
我在dll中加入了一个form,form上是一个ADOConnection和几个ADOQuery,大部分ADOQuery连接到ADOConnection上,一个ADOQuery有单独的连接。
我在DllMain中自己新建了一个TForm,dll释放的时候手动删除,现在发现只要操作数据库,删除form的时候程序就停下来了。不知有什么办法解决。
我的邮箱whyjld@yahoo.com.cn
whyjld@sina.com
whyjld@sohu.com
qq:121145789谢谢
...全文
127 14 打赏 收藏 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
Robin 2003-04-14
  • 打赏
  • 举报
回复
强烈建议奖励invalid(空心菜之2.0开发中) !
另外还有一篇文章推荐!
在delphi中也是关于DLL饿!
是我用另一个号Flyinger1发的!
大家可以看!
是我搜集的一些例子!
抬头看路 2002-09-12
  • 打赏
  • 举报
回复
我估计是ado的问题,编译后患了一台机器就好了。
invalid 2002-07-29
  • 打赏
  • 举报
回复
HRESULT coret=CoInitialize(NULL);
就是判断初试化的返回值啊,
S_OK和S_FALSE好像都可以调用DLL。如果其它的表示失败。
TO:whyjld(白痴) ( )
我上面的代码是在正常运行的程序。
如果不行可能是你的函数代码有问题,跟框架没有关系。
jianlinlong 2002-07-28
  • 打赏
  • 举报
回复
//为什么要用下面这句?
HRESULT coret=CoInitialize(NULL);
//倒底什么意思
coolpony 2002-07-28
  • 打赏
  • 举报
回复
学习
WhyAndAnswer 2002-07-28
  • 打赏
  • 举报
回复
关注
抬头看路 2002-07-28
  • 打赏
  • 举报
回复
我改成数据模块还是不行,谁有办法?
抬头看路 2002-07-22
  • 打赏
  • 举报
回复
但是我改称数据模块后还是有问题。
invalid 2002-07-19
  • 打赏
  • 举报
回复
其它的dll函数,只是简单的调用DM中写好的方法就可以了。
例子如下:
//---------------------------------------------------------------------------
int __stdcall HaveDzd(long _overtime,char* Params,char *message)
{
int ret;
// Zh=Params;
// OverTime=_overtime;
Application->ProcessMessages();
try
{
if(DM->Connect)
ret=DM->HaveDzd(String(Params));
else
{
strcpy(message,"数据库未连接!");
ret=-9999;
}
}
catch(Exception *E)
{
strcpy(message,"查询失败!");
strcat(message,E->Message.c_str());
return -1;
}
return ret;
}

int __stdcall HaveLixi(long _overtime,char* Params,char *message)
{
int ret;
Zh=String(Params);
if(Zh.Length()==14)
Zh="010"+Zh;
Application->ProcessMessages();
try
{
if(DM->Connect)
{
ret=DM->HaveLixi(Zh.c_str());
}
else
{
strcpy(message,"数据库未连接!");
ret=-9999;
}
}
catch(Exception *E)
{
strcpy(message,"查询失败!");
strcat(message,E->Message.c_str());
return -1;
}
return ret;
}
invalid 2002-07-19
  • 打赏
  • 举报
回复
下面是我写的Dll,用ADO连接SQLServer的。
用到了TDataModule,用法是TDataModule中放置ADoconnection。adoquery。adostoreproc...,然后写一些方法完成需要的功能。
使用Dll时先调用OPen,关闭时调用close。
tdm的构造函数中,设置ADoconnection的连接属性。

#include <vcl.h>
#pragma hdrstop
extern "C" __declspec(dllexport) int __stdcall Open(long _overtime,char* Params,char *message);
extern "C" __declspec(dllexport) int __stdcall Close(long _overtime,char* Params,char *message);
extern "C" __declspec(dllexport) int __stdcall HaveDzd(long _overtime,char* Params,char *message);
extern "C" __declspec(dllexport) int __stdcall HaveLixi(long _overtime,char * Params,char *message);
extern "C" __declspec(dllexport) int __stdcall GetDzd(long _overtime,char * Params,char *message);
extern "C" __declspec(dllexport) int __stdcall GetDzdADO(long _overtime,char * Params,char *message);
extern "C" __declspec(dllexport) int __stdcall GetLixi(long _overtime,char * Params,char *message);
extern "C" __declspec(dllexport) int __stdcall SendFile(long _overtime,char* Params,char *file,char *message);
#include "unitSocket.h"
#include "unitdm.h"
//---------------------------------------------------------------------------
// Important note about DLL memory management when your DLL uses the
// static version of the RunTime Library:
//
// If your DLL exports any functions that pass String objects (or structs/
// classes containing nested Strings) as parameter or function results,
// you will need to add the library MEMMGR.LIB to both the DLL project and
// any other projects that use the DLL. You will also need to use MEMMGR.LIB
// if any other projects which use the DLL will be perfomring new or delete
// operations on any non-TObject-derived classes which are exported from the
// DLL. Adding MEMMGR.LIB to your project will change the DLL and its calling
// EXE's to use the BORLNDMM.DLL as their memory manager. In these cases,
// the file BORLNDMM.DLL should be deployed along with your DLL.
//
// To avoid using BORLNDMM.DLL, pass string information using "char *" or
// ShortString parameters.
//
// If your DLL uses the dynamic version of the RTL, you do not need to
// explicitly add MEMMGR.LIB as this will be done implicitly for you
//---------------------------------------------------------------------------
USERES("adodata.res");
USEFORM("unitDm.cpp", DM); /* TDataModule: File Type */
USEFORM("unitSocket.cpp", formSocket);
//---------------------------------------------------------------------------
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*)
{
return 1;
}
//---------------------------------------------------------------------------
int __stdcall Open(long _overtime,char* Params,char *message)
{
int ret=0;
Application->ProcessMessages();
HRESULT coret=CoInitialize(NULL);
switch (coret)
{
case S_OK:
break;
case S_FALSE:
strcpy(message,"Indicates that the library is already initialized or that it could not release default allocator.");
break;
case E_OUTOFMEMORY:
strcpy(message,"Indicates that it was unable to initialize because the system is out of memory.");
break;
case E_INVALIDARG:
strcpy(message,"Indicates the argument is invalid.");
break;
case E_UNEXPECTED:
strcpy(message,"Indicates an unexpected error occurred.");
break;
}
if(coret!=S_OK&&coret!=S_FALSE)
{
return -1;
}
try{
DM=new TDM(NULL);
}
catch(...)
{
strcpy(message,"创建数据模块失败!");
return -1;
}
// Application->CreateForm(__classid(TDM), &DM);
try
{
DM->Connect=true;
}
catch(Exception *E)
{
strcpy(message,"连接数据库失败!");
strcat(message,E->Message.c_str());
CoUninitialize();
return -1;
}
return ret;
}
//---------------------------------------------------------------------------
int __stdcall Close(long _overtime,char* Params,char *message)
{
int ret=0;
Application->ProcessMessages();
if(!DM)
{
strcpy(message,"没有数据模块的实例!");
return -1;
}
try
{
DM->Connect=false;
}
catch(Exception *E)
{
strcpy(message,"断开数据库失败!");
strcat(message,E->Message.c_str());
ret=-8888;
}
try
{
delete DM;
}
catch(...)
{
strcpy(message,"释放数据模块失败");
ret=-9999;
}
CoUninitialize();
return ret;
}
invalid 2002-07-19
  • 打赏
  • 举报
回复
下面是我写的Dll,用ADO连接SQLServer的。
用到了TDataModule,用法是TDataModule中放置ADoconnection。adoquery。adostoreproc...,然后写一些方法完成需要的功能。
使用Dll时先调用OPen,关闭时调用close。
tdm的构造函数中,设置ADoconnection的连接属性。

#include <vcl.h>
#pragma hdrstop
extern "C" __declspec(dllexport) int __stdcall Open(long _overtime,char* Params,char *message);
extern "C" __declspec(dllexport) int __stdcall Close(long _overtime,char* Params,char *message);
extern "C" __declspec(dllexport) int __stdcall HaveDzd(long _overtime,char* Params,char *message);
extern "C" __declspec(dllexport) int __stdcall HaveLixi(long _overtime,char * Params,char *message);
extern "C" __declspec(dllexport) int __stdcall GetDzd(long _overtime,char * Params,char *message);
extern "C" __declspec(dllexport) int __stdcall GetDzdADO(long _overtime,char * Params,char *message);
extern "C" __declspec(dllexport) int __stdcall GetLixi(long _overtime,char * Params,char *message);
extern "C" __declspec(dllexport) int __stdcall SendFile(long _overtime,char* Params,char *file,char *message);
#include "unitSocket.h"
#include "unitdm.h"
//---------------------------------------------------------------------------
// Important note about DLL memory management when your DLL uses the
// static version of the RunTime Library:
//
// If your DLL exports any functions that pass String objects (or structs/
// classes containing nested Strings) as parameter or function results,
// you will need to add the library MEMMGR.LIB to both the DLL project and
// any other projects that use the DLL. You will also need to use MEMMGR.LIB
// if any other projects which use the DLL will be perfomring new or delete
// operations on any non-TObject-derived classes which are exported from the
// DLL. Adding MEMMGR.LIB to your project will change the DLL and its calling
// EXE's to use the BORLNDMM.DLL as their memory manager. In these cases,
// the file BORLNDMM.DLL should be deployed along with your DLL.
//
// To avoid using BORLNDMM.DLL, pass string information using "char *" or
// ShortString parameters.
//
// If your DLL uses the dynamic version of the RTL, you do not need to
// explicitly add MEMMGR.LIB as this will be done implicitly for you
//---------------------------------------------------------------------------
USERES("adodata.res");
USEFORM("unitDm.cpp", DM); /* TDataModule: File Type */
USEFORM("unitSocket.cpp", formSocket);
//---------------------------------------------------------------------------
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*)
{
return 1;
}
//---------------------------------------------------------------------------
int __stdcall Open(long _overtime,char* Params,char *message)
{
int ret=0;
Application->ProcessMessages();
HRESULT coret=CoInitialize(NULL);
switch (coret)
{
case S_OK:
break;
case S_FALSE:
strcpy(message,"Indicates that the library is already initialized or that it could not release default allocator.");
break;
case E_OUTOFMEMORY:
strcpy(message,"Indicates that it was unable to initialize because the system is out of memory.");
break;
case E_INVALIDARG:
strcpy(message,"Indicates the argument is invalid.");
break;
case E_UNEXPECTED:
strcpy(message,"Indicates an unexpected error occurred.");
break;
}
if(coret!=S_OK&&coret!=S_FALSE)
{
return -1;
}
try{
DM=new TDM(NULL);
}
catch(...)
{
strcpy(message,"创建数据模块失败!");
return -1;
}
// Application->CreateForm(__classid(TDM), &DM);
try
{
DM->Connect=true;
}
catch(Exception *E)
{
strcpy(message,"连接数据库失败!");
strcat(message,E->Message.c_str());
CoUninitialize();
return -1;
}
return ret;
}
//---------------------------------------------------------------------------
int __stdcall Close(long _overtime,char* Params,char *message)
{
int ret=0;
Application->ProcessMessages();
if(!DM)
{
strcpy(message,"没有数据模块的实例!");
return -1;
}
try
{
DM->Connect=false;
}
catch(Exception *E)
{
strcpy(message,"断开数据库失败!");
strcat(message,E->Message.c_str());
ret=-8888;
}
try
{
delete DM;
}
catch(...)
{
strcpy(message,"释放数据模块失败");
ret=-9999;
}
CoUninitialize();
return ret;
}
钛哥 2002-07-19
  • 打赏
  • 举报
回复
用DataModule 还是非常有道理的,否则Borland不会强烈推荐
钛哥 2002-07-19
  • 打赏
  • 举报
回复
ADOConnection和几个ADOQuery 不要放在 form上,用一个DataModule ,数据库控件全部放在里面。
钛哥 2002-07-19
  • 打赏
  • 举报
回复
ADOConnection和几个ADOQuery 不要放在form上,用一个DATAModule ,数据库控件全部放在里面。
源码直接下载地址: https://pan.quark.cn/s/a4b39357ea24 【FAST FWR310 无线路由更新程序】是一个专门为FAST FWR310型号无线路由设备设计的固件升级方案,其主要目的在于改善设备的工作表现、纠正已知的系统缺陷或引入全新的操作特性。对无线路由器进行固件更新,实质上是指替换或升级其核心操作系统(即固件),从而使其运行状态得到进一步优化。 在无线路由器的持续使用阶段,用户有时会遭遇若干操作难题,例如网络连接的频繁中断、数据传输速率不高、无线信号覆盖范围有限等情况。针对此类挑战,通过安装新的固件(即刷机包),能够有效应对上述问题,因为新固件或许已经针对这些普遍存在的问题进行了优化处理。不仅如此,固件升级还能开启一些隐藏的功能选项,或者兼容第三方固件,例如OpenWRT,从而让用户能够进行更深入的系统自定义配置及管理。 FWR310 V5.0升级软件20160301是该刷机包的明确版本标识,显示出这是针对FAST FWR310路由器推出的第五代固件,并且发布日期为2016年3月1日。此版本的更新内容可能涵盖以下几个方面: 1. 运行效能的调优:借助于对路由器处理流程与内存分配的改善,能够加快数据交换速率,减少响应时间,从而全面提升网络的工作效能。 2. 安全防护的强化:更新内容中可能融入了对新兴网络安全风险的防御机制,用以保障用户的资料安全。 3. 互操作性的扩展:可能增强了与更多设备及协议的适配能力,比如最新的无线通信标准或设备连接模式。 4. 运行稳定性的提升:修复了可能引发路由器系统崩溃或意外重启的已知故障,延长了设备的稳定运行周期。 5. 新特性集成:或许增添了提升用户体验的功能,例如远程操作控制、家长监管功能、服务质...
内容概要:本文围绕基于混沌系统与DNA编码的彩色图像加密解密体系展开研究,旨在解决传统图像加密算法密钥空间小、抗干扰能力弱等问题。通过结合混沌系统的伪随机性与DNA编码的高维组合特性,构建了多层级、高复杂度的加密框架,实现了对彩色图像RGB三通道的混淆与扩散操作。研究重点包括加密算法的设计与实现、密钥敏感性分析以及抗噪声和抗裁剪性能的系统性测试。实验结果表明,该算法在面对高斯噪声、椒盐噪声及不同面积、位置的图像裁剪攻击时,仍能较好地恢复图像主体结构与核心信息,展现出优良的鲁棒性和实用性。文章还总结了当前研究的不足,并对未来优化方向进行了展望。; 适合人群:具备一定信息安全、图像处理或密码学基础知识的科研人员、研究生及工程技术人员。; 使用场景及目标:①用于高安全性需求下的图像传输与存储场景,如军事通信、医疗影像保护等;②为复合型图像加密技术的研究提供理论支持与实验依据,推动加密算法向高鲁棒性、强抗攻击能力方向发展; 阅读建议:建议读者结合文中提供的理论基础与实验分析,深入理解混沌与DNA编码的融合机制,并可通过复现实验进一步掌握算法细节与性能边界,重点关注抗干扰测试部分以评估其在实际应用中的可靠性。

13,871

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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