Friday, March 30, 2012
running a vb.net dll from sql server
overnight processing.
Originally the idea was to schedule a job on the server to run for each
database that needs the processing completed.
Whats the best way to do this?
we are using vs 2003, ms slq server 2000
1) All the code to execute is in a vb.net dll
2) needs to be run against one or more databases
suggestions?There are a number of ways to accomplish this. One method is to wrap your
DLL in a command-line EXE that takes arguments for server, database, etc.
and then schedule a SQL Agent job with a CmdExec step for each database.
Hope this helps.
Dan Guzman
SQL Server MVP
"Claude Hebert" <chebert@.rvmags.com> wrote in message
news:ug8QC2$JGHA.2392@.TK2MSFTNGP09.phx.gbl...
> We have a new application were building which includes a module to preform
> overnight processing.
> Originally the idea was to schedule a job on the server to run for each
> database that needs the processing completed.
> Whats the best way to do this?
> we are using vs 2003, ms slq server 2000
> 1) All the code to execute is in a vb.net dll
> 2) needs to be run against one or more databases
> suggestions?
>|||....my first thought is that the VB.Net app logs in and does its thing.
In the old days, I'd write my dll in VB6 and use an ActiveX DTS or TSQL
sp_OACreate.
HTH
JeffP...
"Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
news:uHSQD$$JGHA.3276@.TK2MSFTNGP09.phx.gbl...
> There are a number of ways to accomplish this. One method is to wrap your
> DLL in a command-line EXE that takes arguments for server, database, etc.
> and then schedule a SQL Agent job with a CmdExec step for each database.
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Claude Hebert" <chebert@.rvmags.com> wrote in message
> news:ug8QC2$JGHA.2392@.TK2MSFTNGP09.phx.gbl...
>|||What about using rundll32.exe?
--
Andrey Odegov
avodeGOV@.yandex.ru
(remove GOV to respond)|||the best method is to do with
SP_OACreate procedure
steps are :
1. if u r using vb.net dll then make sure the value of Register for COM
Interop value TRUE in Project properties ->Configuration Properties
->Build.
2. add strongname with ur project by sn -k utility.
3. publish ur dll in GAC
4. put ur dll and tlb in system32
5. register ur tlb using regtlibv12 tools
6. in sql server stored procedure create a object of tha dll by using
sp_OACreate.
7.use sp_OAMethod to access methods of that Dll.
8. use sp_OAGetProperty,sp_OASetProperty for getting or setting values.
9. use sp_OADestroy to destroy the object at last.
this is really simple.
if u need example for this then mail me personally at
kissvineet@.yahoo.com
Monday, March 26, 2012
Running a DLL in the Query Analyzer
I have a DLL that I want to run from the Query Analyzer. I tried the
following:
USE master;
EXEC sp_addextendedproc BLAH, '\\Other-Server\Path\To\Blah\Blah.dll'
and I get the error:
ODBC: Msg 0, Level 16, State 1
Cannot load the DLL \\Other-Server\Path\To\Blah\Blah.dll, or one of
the DLLs it references. Reason: 126(The specified module could not be
found.).
The DLL was written in Cobol. The "Other-Server" in the Path above is
the server that Cobol (and the DLL) is located on.
I looked at the dependencies for the DLL and it includes (not
surprisingly) Cobol Dll's. It should find those on the other server.
What can I do?
Thanks!One other thing...
The DLL can be called from Visual Basic. That was installed some time
ago and works great.
On Nov 23, 9:15 am, Jim <jsh...@.datamann.comwrote:
Quote:
Originally Posted by
Hi,
>
I have a DLL that I want to run from the Query Analyzer. I tried the
following:
>
USE master;
EXEC sp_addextendedproc BLAH, '\\Other-Server\Path\To\Blah\Blah.dll'
>
and I get the error:
>
ODBC: Msg 0, Level 16, State 1
Cannot load the DLL \\Other-Server\Path\To\Blah\Blah.dll, or one of
the DLLs it references. Reason: 126(The specified module could not be
found.).
>
The DLL was written in Cobol. The "Other-Server" in the Path above is
the server that Cobol (and the DLL) is located on.
>
I looked at the dependencies for the DLL and it includes (not
surprisingly) Cobol Dll's. It should find those on the other server.
>
What can I do?
>
Thanks!
Quote:
Originally Posted by
the server that Cobol (and the DLL) is located on.
Not just any DLL can run as a SQL Server extended stored procedure.
Extended stored procedures are usually written in C/C++, although I've heard
that some have been written using Delphi. See Creating Extended Stored
Procedures in the Books Online for details.
Separately, COM DLLs can be invoked using sp_OA* procs.
--
Hope this helps.
Dan Guzman
SQL Server MVP
"Jim" <jshain@.datamann.comwrote in message
news:8d9db5fa-a277-400f-9761-7886f9607c55@.g21g2000hsh.googlegroups.com...
Quote:
Originally Posted by
>
Hi,
>
I have a DLL that I want to run from the Query Analyzer. I tried the
following:
>
USE master;
EXEC sp_addextendedproc BLAH, '\\Other-Server\Path\To\Blah\Blah.dll'
>
and I get the error:
>
ODBC: Msg 0, Level 16, State 1
Cannot load the DLL \\Other-Server\Path\To\Blah\Blah.dll, or one of
the DLLs it references. Reason: 126(The specified module could not be
found.).
>
The DLL was written in Cobol. The "Other-Server" in the Path above is
the server that Cobol (and the DLL) is located on.
>
I looked at the dependencies for the DLL and it includes (not
surprisingly) Cobol Dll's. It should find those on the other server.
>
What can I do?
>
Thanks!
>
>
>
>
new DLL using the VB program and use that to access the needed DLL?
If not... If I can call my needed DLL from a C/C++ program, can I
create a new DLL that I could call to get at my needed DLL?
The DLL that I need to call, was bought from a different company, so I
don't have access to the code.
Thanks alot!
Jim
On Nov 24, 9:52 am, "Dan Guzman" <guzma...@.nospam-
online.sbcglobal.netwrote:
Quote:
Originally Posted by
Quote:
Originally Posted by
The DLL was written in Cobol. The "Other-Server" in the Path above is
the server that Cobol (and the DLL) is located on.
>
Not just any DLL can run as a SQL Server extended stored procedure.
Extended stored procedures are usually written in C/C++, although I've heard
that some have been written using Delphi. See Creating Extended Stored
Procedures in the Books Online for details.
>
Separately, COM DLLs can be invoked using sp_OA* procs.
>
--
Hope this helps.
>
Dan Guzman
SQL Server MVP
>
"Jim" <jsh...@.datamann.comwrote in message
>
news:8d9db5fa-a277-400f-9761-7886f9607c55@.g21g2000hsh.googlegroups.com...
>
>
>
>
>
Quote:
Originally Posted by
Hi,
>
Quote:
Originally Posted by
I have a DLL that I want to run from the Query Analyzer. I tried the
following:
>
Quote:
Originally Posted by
USE master;
EXEC sp_addextendedproc BLAH, '\\Other-Server\Path\To\Blah\Blah.dll'
>
Quote:
Originally Posted by
and I get the error:
>
Quote:
Originally Posted by
ODBC: Msg 0, Level 16, State 1
Cannot load the DLL \\Other-Server\Path\To\Blah\Blah.dll, or one of
the DLLs it references. Reason: 126(The specified module could not be
found.).
>
Quote:
Originally Posted by
The DLL was written in Cobol. The "Other-Server" in the Path above is
the server that Cobol (and the DLL) is located on.
>
Quote:
Originally Posted by
I looked at the dependencies for the DLL and it includes (not
surprisingly) Cobol Dll's. It should find those on the other server.
>
Quote:
Originally Posted by
What can I do?
>
Quote:
Originally Posted by
Thanks!- Hide quoted text -
>
- Show quoted text -|||(jimshain@.gmail.com) writes:
Quote:
Originally Posted by
Since I can call it from a VB program, do you know if I can create a
new DLL using the VB program and use that to access the needed DLL?
If not... If I can call my needed DLL from a C/C++ program, can I
create a new DLL that I could call to get at my needed DLL?
>
The DLL that I need to call, was bought from a different company, so I
don't have access to the code.
Yes, you could write one or more extended stored procedures to access
the DLL. Or implement COM methods.
On SQL 2005, you could to a COM-interop and call it from CLR.
Whatever, it's a bit of work, and and if you have errors in your
code that causes access violation, you could crash SQL Server.
To get information about writing extended stored procedures, please
see in Books Online for details. If you have never done it before,
expect at least 50 hours of development.
--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Thanks for the pointers!
Jim
On Nov 26, 5:35 pm, Erland Sommarskog <esq...@.sommarskog.sewrote:
Quote:
Originally Posted by
(jimsh...@.gmail.com) writes:
Quote:
Originally Posted by
Since I can call it from a VB program, do you know if I can create a
new DLL using the VB program and use that to access the needed DLL?
If not... If I can call my needed DLL from a C/C++ program, can I
create a new DLL that I could call to get at my needed DLL?
>
Quote:
Originally Posted by
The DLL that I need to call, was bought from a different company, so I
don't have access to the code.
>
Yes, you could write one or more extended stored procedures to access
the DLL. Or implement COM methods.
>
On SQL 2005, you could to a COM-interop and call it from CLR.
>
Whatever, it's a bit of work, and and if you have errors in your
code that causes access violation, you could crash SQL Server.
>
To get information about writing extended stored procedures, please
see in Books Online for details. If you have never done it before,
expect at least 50 hours of development.
>
--
Erland Sommarskog, SQL Server MVP, esq...@.sommarskog.se
>
Books Online for SQL Server 2005 athttp://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books...
Books Online for SQL Server 2000 athttp://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Friday, March 9, 2012
Run Dll In Stored Procedure
How Can I Run Dll file In Stored Procedure To Return Hard Disk Serial No
ThanksOr How Do something Like This in stored procedure
FSO=CREATEOBJECT('Scripting.FileSystemObject')
fso.Drives('C').SerialNumber|||Look up the set of "sp_OA* " system procedures in Books Online.
Maybe you can start here:
http://msdn.microsoft.com/library/d...r />
_05bm.asp
ML
http://milambda.blogspot.com/|||Thanks ML
"ML" <ML@.discussions.microsoft.com> wrote in message
news:6D24B363-3D92-4E53-9BF1-6E26FFACA338@.microsoft.com...
> Look up the set of "sp_OA* " system procedures in Books Online.
> Maybe you can start here:
> http://msdn.microsoft.com/library/d.../>
22_05bm.asp
>
> ML
> --
> http://milambda.blogspot.com/