-
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
-
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
-
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!)