CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: DLL error

  1. #1
    Join Date
    Aug 2000
    Location
    South Africa
    Posts
    195

    DLL error

    Hi

    I'm developing a Data Tier that just makes a connection to a db. The configuration is as follows:
    dll = PdataTier.clsemps
    SQLserver name = Lorna
    DB name = LornaDB
    Table name = EMPS

    Code looks as follows


    private Sub Class_Initialize()
    set cnMaindata = new ADODB.Connection
    With cnMaindata
    .Provider = "SQLOLEDB.1;Persist Security Info=false;User ID=sa;Initial Catalog=LornaDB;Data Source=LORNA"
    .DefaultDatabase = "lornadb"
    .Open
    End With

    set rsEmps = new ADODB.Recordset

    rsEmps.Open "Emps", cnMaindata, adOpenDynamic, adLockOptimistic

    End Sub




    I created an Exe project just to check that the dll connects - I need to use late binding for this project (it becomes a distributed App later on...)



    Dim P as Object
    private Sub Command1_Click()
    set P = CreateObject("pdataTier.clsemps", "Lorna")
    End Sub





    when the exe runs, I get the error message " OPERATION IS NOT ALLOWED WHEN THE OBJECT IS CLOSED" NO 3704

    I'm new to all this - can anyone help me?

    Thanx




  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: DLL error


    'This may help in finding matter (which I think is about the connection, ie:
    'database name mispelled (ucase,lowcase...) )
    option Explicit
    private cnMaindata as ADODB.Connection
    private rsEmps as ADODB.Recordset

    private Sub Class_Initialize()
    dim lngCount as long
    set cnMaindata = new ADODB.Connection
    With cnMaindata
    .Provider = "SQLOLEDB.1;Persist Security Info=false;User ID=sa;Initial Catalog=LornaDB;Data Source=LORNA"
    .DefaultDatabase = "lornadb"
    .Open
    End With

    Do while lngCount < 1000
    DoEvents
    If (cnMaindata.State = adStateOpen) then
    Exit Do
    else
    Debug.print cnMaindata.State
    lngCount = lngCount +1

    End If
    Loop

    set rsEmps = new ADODB.Recordset

    rsEmps.Open "Emps", cnMaindata, adOpenDynamic, adLockOptimistic

    End Sub







    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  3. #3
    Join Date
    Sep 2001
    Location
    Hertford
    Posts
    1

    Re: DLL error

    Your problem is nothing to do with lowercae / uppercase as unless you have changed the defalt configuration SQL Server is case insensitive. From the code you have posted it looks as though you haven't set an active connection for the recordset so it cannot open. Use following code
    Set rs.ActiveConnection = con (obviously replacing variable names with yours!)



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured