
Connect to SQL-Server 6.5
Could be a problem with the way the objects are created. I normally use
CreateInstance in MTS objects. The following code handles cases when the
class is called from MTS or from VB:
Dim Context As MTxAS.ObjectContext
Dim lDb As DAO.Database
On Error GoTo badCreate
Set Context = GetObjectContext()
If Not Context Is Nothing Then
Set lDb = GetObjectContext().CreateInstance("DAO.Database")
Set Context = Nothing
Else
Set lDb = CreateObject("DAO.Database")
End If
Quote:
> I have a problem connecting to SQLServer 6.5 from an object created
through
> Transaction Server.
> If the same object is created without MTS (hence running in the clients
> process) the connection
> works OK.
> I'm using ODBC to communicate with the database.
> The code which makes the connection is:
> Dim lstrConnect As String
> Dim lDb As DAO.Database
> lstrConnect = "ODBC;DSN=OPAL;UID=SA;PWD=;DATABASE=OPAL;"
> Set lDb = OpenDatabase("", False, False, lstrConnect)
> The error returned is
> [91] Object variable or With block variable not set.
> I know the ODBC-connection works since I, in another part of the
> application, create an object, via MTS, built in
> COBOL. This object uses the same ODBC and everything is working as we
want
> to.
> What can the problem be?