Showing posts with label dll. Show all posts
Showing posts with label dll. Show all posts

Sunday, March 25, 2012

Does sp_OA_Create work with .Net?

Does anyone know if a .Net DLL will work similar to a VB6 DLL using
sp_OA_Create?
TIA
JeffP...It is not supported for extended stored procedures or sp_OA procedures to ca
ll .NET code in CLR;
hosted within SQL Server's address space..
See:
http://support.microsoft.com/defaul...kb;en-us;322884
Also, below is with permission from David Browne, explaining how you can hav
e SQL Server execute CLR
code executing in its own process:
"
Short answer: Don't do it.
Calling managed code inside a stored procedure is not supported.
http://support.microsoft.com/defaul...kb;en-us;322884
At least not directly. You need some sort of unmanaged proxy to communicate
with your component running in another process.
For instance, http, or, drum roll, a COM+ Server Application.
This will cause COM+ to load an unmanaged proxy object in the SqlServer
process and will load the CLR into a COM+ surrogate process (dllhost.exe).
Which somebody here mentioned last w, and I just got around to testing.
It's all perfectly transparent to you, but you have to set up the COM+
server application.
Remember this is something different from .net remoting. With .NET remoting
you have a _managed_ proxy object in the local process, and so you load the
CLR in the local process as well as the remote process.
Anyway here's what I did:
I created this VB class
comTest.vb listing:
Imports System.Runtime.InteropServices
<ClassInterface(ClassInterfaceType.AutoDual),
ProgId("comTest.comTestClass")> _
Public Class comTest
Public Function Hello() As String
Return "hello"
End Function
End Class
build comTest.dll and registered it with
regasm /codebase comTest.dll /tlb:comTest.tlb
(complains that I haven't strong-named my assembly, which you should do.)
created an empty COM+ server application, set to run under a local
administrator account, and dragged comTest.dll into its components folder.
created an unmanaged host (vbscript will do), and invoked the component
using IDispach just like SQLServer.
test.vbs listing
Set d = CreateObject("comTest.comTestClass")
MsgBox d.Hello
Then I used the .net command line debugger cordbg.exe's 'pro' command to
list the processes hosting the CLR. And procexp.exe from
www.sysinternals.com to verify that the CLR's dll's were not loaded in my
unmanaged process. My unmanaged host did not load the CLR, although it
loaded "comsvcs.dll", and the CLR was loaded by the dllhost.exe process.
Then in sql I ran
declare @.object int
declare @.msg varchar(50)
declare @.rc int
declare @.hr int
declare @.source varchar(1000)
declare @.description varchar(1000)
exec @.rc = sp_oacreate 'comTest.comTestClass', @.object output
if @.rc <> 0
begin
EXEC @.hr = sp_OAGetErrorInfo @.object, @.source OUT, @.description OUT
print 'create failed ' + @.description
return
end
exec @.rc = sp_oamethod @.object, 'Hello', @.msg output
if @.rc <> 0
begin
EXEC @.hr = sp_OAGetErrorInfo @.object, @.source OUT, @.description OUT
print 'method failed ' + @.description
return
end
print 'return: ' + @.msg
exec @.rc = sp_oadestroy @.object
if @.rc <> 0
begin
EXEC @.hr = sp_OAGetErrorInfo @.object, @.source OUT, @.description OUT
print 'destroy failed ' + @.description
return
end
Ran fine, and still only one CLR loaded into dllhost.exe's process. So
think we can safely conclude that COM+ server applications do not violate
the prohibition against running managed code in SQLServer's process and
provide a convenient mechanism for interoperating with managed code from
TSQL.
David
"
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"JDP@.Work" <JPGMTNoSpam@.sbcglobal.net> wrote in message
news:eXAIE000FHA.2932@.TK2MSFTNGP10.phx.gbl...
> Does anyone know if a .Net DLL will work similar to a VB6 DLL using
> sp_OA_Create?
> TIA
> JeffP...
>

Monday, March 19, 2012

does not install SQL Query Analyzer

Hi,

I am developing and application in pocket pc windows mobile 2003. I have added a reference to System.Data.SqlServerCe.dll but when i deploy the application query analyzer doesnt seem to install. Any help please?

cheers,

michael

Hi,

Sorry... for info I am using CS VS2005 and SQL Mobile.

Thank you.

michael

|||

Query Analyzer 3.0 should deploy automatically if you are building and deploying a DEBUG build in VS2005 given your reference to System.Data.SqlServerCe.dll version 2.0. You can also just grab the dev tools CAB and install it to your device/emulator to save time. it is located (depending on your device's WinCE kernel) at:

<drive:>\Program Files\Microsoft Visual Studio 8\SmartDevices\SDK\SQL Server\Mobile\v3.0\wce400\armv4\sqlce30.dev.ENU.ppc.wce4.armv4.CAB

or

C:\Program Files\Microsoft Visual Studio 8\SmartDevices\SDK\SQL Server\Mobile\v3.0\wce500\<device CPU architecture>\

Darren

Friday, February 24, 2012

Dodgy Results AS400 linked server

Hi
I have an AS400 linked server in SQL Server 2000. Using IBM's iSeries Access
ODBC Driver (filename : CWBODBC.DLL, Ver 9.00.08.00).
When I run a query in query analyser it does not return all of the records.
I am getting "Error converting data type DBTYPE_DBTIMESTAMP to datetime."
It definitely is not returning all of rows as SELECT COUNT(*) FROM ...
reveals that there are more records. Whereas SELECT * ... returns only a
subset of the data and reports the error above.
If I omit the date field I get all of the rows. i.e. SELECT ColA as
NonDateField FROM ...
Also if I select just the datefield, I get more rows i.e. SELECT ColB as
ThisIsTheDateField FROM ... I get more rows than SELECT * FROM ... but not
all of them.
Whats going on?!!!
It almost seems as though there is some sort of buffer/bytes limit on the
data that it can return.
Do you guys who have a linked AS400 get all of your required data ?
Sorry this bit in my previous post ;
"Also if I select just the datefield, I get more rows i.e. SELECT ColB as
ThisIsTheDateField FROM ... I get more rows than SELECT * FROM ... but not
all of them. "
is incorrect please ignore (I get the same number of rows)
|||Interfacing with an AS400 can work and be stable but you
need the right driver or provider, need to keep it current,
need to keep up on any necessary service packs for it, etc.
I used Client Access and the HIT software providers for
AS400s before. HIT providers were good and we didn't run
into many problems(if any really) with their drivers or
providers. IBMs drivers weren't as stable.
What you are hitting isn't likely to be a SQL Server issue -
more likely related to the driver or the client setup,
dependent files for the driver.
-Sue
On Wed, 2 May 2007 07:18:01 -0700, Jane
<Jane@.discussions.microsoft.com> wrote:

>Sorry this bit in my previous post ;
>"Also if I select just the datefield, I get more rows i.e. SELECT ColB as
>ThisIsTheDateField FROM ... I get more rows than SELECT * FROM ... but not
>all of them. "
>is incorrect please ignore (I get the same number of rows)

Dodgy Results AS400 linked server

Hi
I have an AS400 linked server in SQL Server 2000. Using IBM's iSeries Access
ODBC Driver (filename : CWBODBC.DLL, Ver 9.00.08.00).
When I run a query in query analyser it does not return all of the records.
I am getting "Error converting data type DBTYPE_DBTIMESTAMP to datetime."
It definitely is not returning all of rows as SELECT COUNT(*) FROM ...
reveals that there are more records. Whereas SELECT * ... returns only a
subset of the data and reports the error above.
If I omit the date field I get all of the rows. i.e. SELECT ColA as
NonDateField FROM ...
Also if I select just the datefield, I get more rows i.e. SELECT ColB as
ThisIsTheDateField FROM ... I get more rows than SELECT * FROM ... but not
all of them.
Whats going on'!!!
It almost seems as though there is some sort of buffer/bytes limit on the
data that it can return.
Do you guys who have a linked AS400 get all of your required data ?Sorry this bit in my previous post ;
"Also if I select just the datefield, I get more rows i.e. SELECT ColB as
ThisIsTheDateField FROM ... I get more rows than SELECT * FROM ... but not
all of them. "
is incorrect please ignore (I get the same number of rows)|||Interfacing with an AS400 can work and be stable but you
need the right driver or provider, need to keep it current,
need to keep up on any necessary service packs for it, etc.
I used Client Access and the HIT software providers for
AS400s before. HIT providers were good and we didn't run
into many problems(if any really) with their drivers or
providers. IBMs drivers weren't as stable.
What you are hitting isn't likely to be a SQL Server issue -
more likely related to the driver or the client setup,
dependent files for the driver.
-Sue
On Wed, 2 May 2007 07:18:01 -0700, Jane
<Jane@.discussions.microsoft.com> wrote:

>Sorry this bit in my previous post ;
>"Also if I select just the datefield, I get more rows i.e. SELECT ColB as
>ThisIsTheDateField FROM ... I get more rows than SELECT * FROM ... but no
t
>all of them. "
>is incorrect please ignore (I get the same number of rows)