-
Jul 23rd, 2014, 07:27 AM
#1
Thread Starter
Addicted Member
how to use vb6 dll in sql server 2012 ?
i have create a dll in vb6 and want to call its method from sql server store procedure.
i have try below code
Code:
CREATE ASSEMBLY t
AUTHORIZATION dbo
FROM '\\EMPEROR12\ClientData\Bhimraj\updatelibsrc.dll'
WITH PERMISSION_SET = UNSAFE
go
But this give below error.
Code:
Msg 6544, Level 16, State 1, Line 1
CREATE ASSEMBLY for assembly 'myassem' failed because assembly 'myassem' is malformed or not a pure .NET assembly.
Unverifiable PE Header/native stub.
Please help me
-
Jul 23rd, 2014, 08:09 AM
#2
Re: how to use vb6 dll in sql server 2012 ?
According to the error message a .NET dll is expected, not a DLL created with VB6
-
Jul 23rd, 2014, 08:11 AM
#3
Re: how to use vb6 dll in sql server 2012 ?
Indeed it needs to be managed code in MSIL
The assembly binary is well formed with valid metadata and code segments, and the code segments have valid Microsoft Intermediate language (MSIL) instructions.
http://msdn.microsoft.com/en-us/library/ms189524.aspx
-
Jul 23rd, 2014, 09:01 AM
#4
Thread Starter
Addicted Member
Re: how to use vb6 dll in sql server 2012 ?
so is there is another technique where i can achive this task means calling vb6 dll from sql server..??
-
Jul 23rd, 2014, 11:19 AM
#5
Re: how to use vb6 dll in sql server 2012 ?
Originally Posted by mynameishide
so is there is another technique where i can achive this task means calling vb6 dll from sql server..??
It is hard to say without knowing what you are trying to do. Most of the time I use stored procedures to interact with VB 6.0 and MS SQL.
Please remember next time...elections matter!
-
Jul 24th, 2014, 01:18 AM
#6
Thread Starter
Addicted Member
Re: how to use vb6 dll in sql server 2012 ?
Originally Posted by TysonLPrice
It is hard to say without knowing what you are trying to do. Most of the time I use stored procedures to interact with VB 6.0 and MS SQL.
yes but in my project i want to use same technique like CREATE ASSEMBLY for .net dll..
-
Jul 24th, 2014, 02:19 AM
#7
Re: how to use vb6 dll in sql server 2012 ?
Write your DLL in .NET, or create a wrapper in .NET for your DLL.
-
Jul 24th, 2014, 02:23 AM
#8
Thread Starter
Addicted Member
Re: how to use vb6 dll in sql server 2012 ?
it is very time consuming task to understand code of vb6 and convert it to .net..
-
Jul 24th, 2014, 02:32 AM
#9
Re: how to use vb6 dll in sql server 2012 ?
Did you read the link I posted?
It's clearly stated that only MSIL compiled managed byte code is supported.
Maybe you should read the requirements before you start programming.
-
Jul 24th, 2014, 05:29 PM
#10
Re: how to use vb6 dll in sql server 2012 ?
Originally Posted by mynameishide
so is there is another technique where i can achive this task means calling vb6 dll from sql server..??
As others have said, you cannot do this. SQL Server from 2005 has the ability to host the CLR which means it can only execute MSIL bytecode. If you really need your VB6 DLL to run then I suggest you create a stub in a .Net language that imports the VB6 DLL and have SQL Server use this stub.
-
Jul 24th, 2014, 05:36 PM
#11
Re: how to use vb6 dll in sql server 2012 ?
Come to think about it, a stub may not even work. If I remembered right, .Net assemblies hosted in SQL Server get access to the server through something called a context connection. Unless you can pass this off as something your COM based VB6 DLL can understand, it might be pointless to even try this in the first place. Of course if your VB6 DLL doesn't actually have to do any database access then this stub idea might just work. Let the .Net stub to all the database access and your VB6 DLL can do whatever it's made to do with whatever data you pass to it from the .Net assembly. Another thing, I'm not entirely certain that a hosted .Net DLL can reference a COM DLL the same way a WinForms app or .Net class library can but it should be able to. I can't see any reason why not but these types of situations always bring up some nasty surprises.
-
Jul 24th, 2014, 07:20 PM
#12
Re: how to use vb6 dll in sql server 2012 ?
if your VB6 DLL doesn't actually have to do any database access
Then why bother?
-tg
-
Jul 24th, 2014, 07:24 PM
#13
Re: how to use vb6 dll in sql server 2012 ?
I'd think you could do this using OLE Automation Stored Procedures (Transact-SQL), remembering that "OLE Automation" is more or less a synonym for ActiveX.
It looks like late binding with calls similar to using VB6's CallByName() function.
-
Jul 24th, 2014, 07:40 PM
#14
Re: how to use vb6 dll in sql server 2012 ?
Originally Posted by techgnome
Then why bother?
-tg
Stored procedures aren't the only thing one can write with CLR integration. You can also write functions. They don't necessarily have to interact directly with SQL Server. Of course I'm just speculating here as I have no idea what kind of work the Op's DLL is supposed to do.
-
Jul 24th, 2014, 07:41 PM
#15
Re: how to use vb6 dll in sql server 2012 ?
Originally Posted by dilettante
I'd think you could do this using OLE Automation Stored Procedures (Transact-SQL), remembering that "OLE Automation" is more or less a synonym for ActiveX.
It looks like late binding with calls similar to using VB6's CallByName() function.
I stand corrected.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|