在dll中使用dao的问题 [英] Problem with dao used in a dll

查看:51
本文介绍了在dll中使用dao的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello

我已经在Visual C ++中将一个使用dao从VS6转换为VS2010的dll。

I have converted a dll that use dao from VS6 to VS2010 in Visual C++.

这个Dll由VS2005 c#应用程序用于此操作

This Dll is used by a VS2005 c# application for this operations

1)OpenDatabase

1) OpenDatabase

2)使用方法 "SearchData"

2) Use method "SearchData" that access to DB opened before

之前打开DB的访问权限3)CloseDatabase

3) CloseDatabase

当我首先启动应用程序时,它使用OpenSeatabase,它使用"SeatchData",然后CloseDatabase。应用程序工作正常,因为我使用的是VS6,但现在当我调用OpenDatabase时,它工作正常,但当我尝试"SearchData"时当我尝试使用之前打开的数据库指针时,有一个错误
。该错误是"试图在受保护的存储器中读取或写入"。允许dll工作的唯一方法是打开db,使用数据访问并关闭每个内部的数据库"SearchData"。方法,但每次
调用需要大量时间,因为我多次调用此方法。对于我的观点,似乎dll不会在调用OpenDatabase和使用"SearchData"之间管理db变量的状态。方法。我已经在每种方法的开头使用AFX_MANAGE_STATE(AfxGetStaticModuleState()
)。

When I start application first of all it OpenDatabase the it use "SeatchData", then CloseDatabase. The application worked fine since I was working with VS6 but now when I call OpenDatabase it works fine but when I try to "SearchData" there is an error when I try to used db pointer opened before. The error is "trying to read or write in protected memory". The only way to allow dll to work is to open db, use data to access and close db every inside "SearchData" method, but this require a lot of time each call because I call this method many time. For my point of view it seem that dll doesn't mantein the status of db variable between a call of OpenDatabase and the use of "SearchData" method. I am already using AFX_MANAGE_STATE ( AfxGetStaticModuleState() ) at the begining of each method.

你能帮助我吗?

非常感谢

推荐答案

你能提供一些代码吗?

或者你可以更清楚地解释这种情况。

or you can explain the situation more clearly.


这篇关于在dll中使用dao的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆