如何使用 ASP.NET 应用程序将 ADODB 连接对象从 VB 组件传递到 C#
我正在执行多个 vb6 组件,这些组件从 asp.net 中访问不同的数据库引擎,例如 access (mdb)、sql server 等。
这些组件已在 vb6 中编译为 dll,并在 ASP.NET Framework 2.0 中添加为引用程序集。每个组件都有几个函数,这些函数将 adodb.connection 对象作为参数传递,并从这些函数中执行 sql 语句。这与分层解决方案模式相当,只是在业务逻辑层中它们传递 adodb.connection 对象而不是连接字符串。这在 VB6 中有效,但在 asp.net 中调用时不起作用,因为当编译器遇到 adodb.connection.open() 时,它会修改 adodb.connection.connectionstring 属性的值。
如何从 adodb.connection 对象获取连接字符串
编辑
这是注释中的getConnstringfromASP
。
public void getConnstringfromASP(ADODB.Connection getadoObjConn)
{
string strAdoobjConnString = "";
strAdoobjConnString = getadoObjConn.ConnectionString;
SqlConnection objConnection = new SqlConnection();
objConnection.ConnectionString = strAdoobjConnString;
}
I am executing multiple vb6 components that accesses different database engines such as access (mdb), sql server, etc from within asp.net.
These components are already compiled dlls in vb6 and added as referenced assembly in asp.net framework 2.0. Each component has several functions that passes the adodb.connection object as parameter and executes sql statements from within these functions. This is comparable to a layered solution pattern, only, in the business logic layer they pass the adodb.connection object instead of the connection string. This works in VB6 but when called in asp.net it won't work because when the compiler encounters the adodb.connection.open() it modifies the value of the adodb.connection.connectionstring property.
How I get connection string from adodb.connection object
EDIT
Here's the getConnstringfromASP
from comments.
public void getConnstringfromASP(ADODB.Connection getadoObjConn)
{
string strAdoobjConnString = "";
strAdoobjConnString = getadoObjConn.ConnectionString;
SqlConnection objConnection = new SqlConnection();
objConnection.ConnectionString = strAdoobjConnString;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为创建连接字符串的代码应该如下所示:
连接字符串在 SqlConnection 对象的构造函数中传递。
I think your code for creating the connection string should look something like this:
the connection string is passed in the constructor of the SqlConnection object.