Results 1 to 15 of 15

Thread: how to use vb6 dll in sql server 2012 ?

  1. #1

    Thread Starter
    Addicted Member mynameishide's Avatar
    Join Date
    Apr 2010
    Posts
    136

    Question 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

  2. #2
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    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

  3. #3
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    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

  4. #4

    Thread Starter
    Addicted Member mynameishide's Avatar
    Join Date
    Apr 2010
    Posts
    136

    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..??

  5. #5
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,834

    Re: how to use vb6 dll in sql server 2012 ?

    Quote Originally Posted by mynameishide View Post
    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!

  6. #6

    Thread Starter
    Addicted Member mynameishide's Avatar
    Join Date
    Apr 2010
    Posts
    136

    Re: how to use vb6 dll in sql server 2012 ?

    Quote Originally Posted by TysonLPrice View Post
    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..

  7. #7
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: how to use vb6 dll in sql server 2012 ?

    Write your DLL in .NET, or create a wrapper in .NET for your DLL.

  8. #8

    Thread Starter
    Addicted Member mynameishide's Avatar
    Join Date
    Apr 2010
    Posts
    136

    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..

  9. #9
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    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.

  10. #10
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: how to use vb6 dll in sql server 2012 ?

    Quote Originally Posted by mynameishide View Post
    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.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  11. #11
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    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.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  12. #12
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  13. #13
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    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.

  14. #14
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: how to use vb6 dll in sql server 2012 ?

    Quote Originally Posted by techgnome View Post
    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.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  15. #15
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: how to use vb6 dll in sql server 2012 ?

    Quote Originally Posted by dilettante View Post
    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.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

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