Connect to SQL-Server 6.5 
Author Message
 Connect to SQL-Server 6.5

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?



Sun, 11 Mar 2001 03:00:00 GMT  
 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?



Mon, 12 Mar 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. ODBC Connect to SQL server 6.5

2. connecting to MS SQL Server 6.5 using VB5

3. Connect to 2 different SQL Server 6.5 db

4. Connect to 2 different SQL server 6.5 Dbs

5. How to connect to SQL Server 6.5 using VB 5.0

6. Connecting to SQL Server 6.5 and 7.0

7. New Transact-SQL Debugger for Microsoft SQL Server 6.5/7.0

8. Import text file in SQL Server 6.5 via SQL in Visual Basic

9. SQL Debugger for Microsoft SQL Server 7.0 and 6.5

10. Import text file in SQL Server 6.5 via SQL in Visual Basic

11. Pls Help-VB4 w/SQL 6.5 can't connect

12. Urgent : VB6 ADO Connecting to SQL 6.5

 

 
Powered by phpBB® Forum Software