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.Connectio开发者_运维问答nString;
SqlConnection objConnection = new SqlConnection();
objConnection.ConnectionString = strAdoobjConnString;
}
I think your code for creating the connection string should look something like this:
public void getConnstringfromASP(ADODB.Connection getadoObjConn)
{
string strAdoObjConnString = getadoObjConn.ConnectionString;
SqlConnection objConnection = new SqlConnection(strAdoObjConnString);
}
the connection string is passed in the constructor of the SqlConnection object.
精彩评论