For the reason beyond my control I am forced to use oa_spcreate functionality from within SQL Server 2008 R2 64bit. The old VB6 DLLs (again out of my control) are not supported by 64bit version (32bit consideration is on the way).
I have tried to create a .NET wrapper for some of the functions on the old DLLs. Followed bits and pieces a knocked it together.
Code sample:
namespace Some32bitWrapper
{
[ClassInterface(ClassInterfaceType.None)]
public class Dissues32iClass : iDissues32iClass
{
public Dissues32iClass()
{
}
//Instantiate iclass and execute InsertLocDetailLinesOnServer
public Object InsertLocDetailLinesOnServer(String ConnectString, String DetailsString, int User)
{
try
{
DIssues32.Iclass _iclass = new Iclass();
Object _return = _iclass.InsertLocDetailLinesOnServer(ConnectString, DetailsString, User);
return _return;
}
catch (Exception er)
{
return er.Message;
}
}
}
public interface iDissues32iClass
{
Object InsertLocDetailLinesOnServer(String ConnectString, String DetailsString, int User);
}
}
Complied, registered with tlb regasm and tlb, gacutil-ed it. All seems honky-dory. As soon as I try run it from within SQL stored procedure using sp_oacreate get "Class not registered" error.
Stored Proc code:
ALTER PROCEDURE [dbo].[DIME_InsertLocDetailLinesOnServer]
@tConnectionString varchar(255),
@SysUser int,
@tDetailsString text
AS
declare @hr int
declare @Object int
declare @Return int
declare @Output varchar(255)
--HKEY_CLASSES_ROOT\TypeLib\{492BF323-0691-4F62-9171-3F75F4DF2753}
exec @hr= sp_OACreate 'Some32bitWrapper.Dissues32iClass',@object out,5
IF @hr <> 0
BEGIN
EXEC sp_Getoaerrorinfo @object, @hr,@output out
select @output,@hr
RETURN -2
END
else
return 'registered'
begin
exec @hr = sp_OAMethod @object,'InsertLocDetailLinesOnServer',NULL, @ConnectString = @tConnectionString,
@DetailsString = @tDetailsString,@User = @Sysuser
IF @hr <> 0
BEGIN
EXEC sp_Getoaerrorinfo @object, @hr,@output out
select @output
RETURN -3
END
exec @hr= sp_OADestroy @object out
print @return
end
Not a lot of information on it, except "don't use don't use types". At this time do not have a choice. Anybody can help?
P.S.: I ran all of the required reconfigure options on SQL Server and permission grants.