Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 sp_OACreate and sp_OAMethed Heelllllpppp...

Author  Topic 

pcplayer
Starting Member

5 Posts

Posted - 2008-03-23 : 00:12:44
I have a question and I hoping to not sound to lame. I am trying to use the sp_oacreate and the sp_oamethed to run my dll from sql sever 2005
It looks some thing like this

EXEC @hr = sp_OACreate 'MyApplication.Adcom', @object OUT,5
IF @hr <> 0
BEGIN --Not able to create the object
Return @hr
END --Not able to create the object

EXEC @hr = sp_OAMethod @object, 'Authenticate', @FunctionReturn OUT, strUser, strPassword, strDoman
IF @hr <> 0
BEGIN --Not able to execute Com function
Return @hr
END --Not able to execute Com function

I have created my dll in .net and placed it in the root drive of the server. How does OACreate know where to locate my dll?
One executing this fucntion I am returning -2147221005
-214721148 error code.

Have I created my dll incorrectly? The name of the dll is ActiveDirectoryCom and the Class with in the dll is called Adcom and the function that need to run is called AuthenticateUserFullPath. Have I correctly Written the sp_Oa's

mfemenel
Professor Frink

1421 Posts

Posted - 2008-03-23 : 05:31:12
Well it's been a while since I've done this in sql but did you run regserver32? I believe you would need to register your DLL before using it.
Regsvr32.exe <DLL PATH>\DLLNAME.dll

Mike
"oh, that monkey is going to pay"
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2008-03-23 : 08:27:28
You should use the standard CLR integration features of SQL 2005 to call .net code.

http://www.devsource.com/c/a/Using-VS/Introducing-SQL-Server-2005s-CLR-Integration/

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

pcplayer
Starting Member

5 Posts

Posted - 2008-03-23 : 22:39:39
I have tried to use CRL integration in SQL Server 2005 manage it with CREATE ASSEMBLY statement. However that ole automation application that I am trying to execute with the above stored proceedure has a company web service that is a company standard to do the authentication which I have no contol over, So when I try to execute:

CREATE ASSEMBLY ActiveDirectoryCom from 'C:\ActiveDirectoryCom\bin\Release\ActiveDirectoryCom.dll' WITH PERMISSION_SET = SAFE

I get this error

Msg 6213, Level 16, State 1, Line 6
CREATE ASSEMBLY failed because method "add_LookupUserInfoFromIDCompleted" on type "ActiveDirectoryCom.com.cshPeopleFinder" in safe assembly "ActiveDirectoryCom" has a synchronized attribute. Explicit synchronization is not allowed in safe assemblies.

cshPeopleFinder is a webreference to a webservice. I how that there is many other ways to do this however It is requested that I keep this functionality runing with this stored procedure and that the dll remain on the the secure server.
Go to Top of Page
   

- Advertisement -