Re: T-SQL and OLE Automation
From: Greg Linwood (g_linwoodQhotmail.com)
Date: 08/16/04
- Next message: Guadala Harry: "Deleting Multiple Rows"
- Previous message: Anith Sen: "Re: Unlocking a Databse"
- In reply to: Larry Menzin: "Re: T-SQL and OLE Automation"
- Next in thread: Larry Menzin: "Re: T-SQL and OLE Automation"
- Reply: Larry Menzin: "Re: T-SQL and OLE Automation"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 17 Aug 2004 07:04:36 +1000
Hi Larry.
To write the VB6 app, you simply create a class library using a project of
either the ActiveX.dll or ActiveX.exe project types. They are essentially
the same in terms of how you go about developing them from the VB side,
except that a library created as a .dll will run inside the SQL Server
process, therefore sharing & competing for memory with the main SQL process.
A library created as type ActiveX.exe will run out of the SQL Server
process, using it's own memory and can therefore be run remotely on another
machine (using DCOM or COM+) and / or under a different user context.
Once you choose what library type you want to create, you simply add class
files, add properties & methods to implement whatever behaviour you need,
being careful of the parameter type conversion issues I referred to earlier.
To deploy a .dll, you make it, using the VB6 file/make command, then copy to
the server & use the regsvr32.exe utility program, which is very
straight-forward. To deploy an ActiveX.exe, you make it, copy to the server
then simply double click it as it has self-registering code.
Creating COM libraries with VB6 is probably better discussed in a VB
newsgroup but if you want more help here I'm happy to help. So definitely
post back if you've got more questions. I'm not sure of any specific KB
articles that actually show how to create a VB6.dll or ActiveX.exe but do
make sure you understand the difference between an ActiveX.exe and a
standard .exe as they're different. You can't access standard .exe's from
SQL Server using OLE. You need either an ActiveX.dll or ActiveX.exe project
to do that.
HTH
Regards,
Greg Linwood
SQL Server MVP
"Larry Menzin" <LarryMenzin@discussions.microsoft.com> wrote in message
news:B54EB985-707F-4B81-AB0D-C49C042EB152@microsoft.com...
> Greg,
>
> Thanks. I saw those pages in BOL. They are examples of SQL server
accessing
> SQL server via OLE automation. My application is to run VB6 EXE files via
SQL
> OLE automation and I'm not sure how to write the application on the VB6
side
> to make this automation work. Does MS have anything to help me there?
>
> Thanks,
>
> Larry
>
> "Greg Linwood" wrote:
>
> > Hi Larry
> >
> > There's a good example script in Books Online here:
> > http://msdn.microsoft.com/library/en-us/acdata/ac_8_qd_14_2ktw.asp
> >
> > Another article nearby in BOL worth looking at is
> > "OLE Automation Return Codes and Error Information", at:
> > http://msdn.microsoft.com/library/en-us/acdata/ac_8_qd_14_8k6m.asp
> >
> > Also, do make sure youu carefully check data type compatability between
VB &
> > TSQL as many get tripped on this when starting out with TSQL / OLE.
> > Basically, an Int is not an Int between these languages - a TSQL int is
a
> > VB(6) Long, so do take care when setting out method parameters, returns
etc.
> >
> > HTH
> >
> > Regards,
> > Greg Linwood
> > SQL Server MVP
> >
> > "Larry Menzin" <LarryMenzin@discussions.microsoft.com> wrote in message
> > news:4F43C4E3-D9C3-4EA9-BFA9-C6549F144C4C@microsoft.com...
> > > I am looking for some sample code (preferably VB) to
> > > create an OLE Automation Server that can be accessed via T-
> > > SQL stored procedures using the OLE system stored
> > > procedures. There appears to be little documentation on
> > > how to use this feature. Even a program in VB allowing me
> > > to return "hello world" via T-SQL would be very helpful.
> > >
> > > This seems to be a very powerful feature that may allow me
> > > to integrate external applications with SQL Server via T-
> > > SQL stored procedures. Use of XP_CMDSHELL only returns a 0
> > > or 1 and results in a non-integrated solution.
> > >
> > > Do you have any ideas on this?
> > >
> > > Larry Menzin
> > > American Techsystems Corp.
> > > .
> > >
> > >
> > > --
> > > Larry Menzin
> > > American Techsystems Corp.
> >
> >
> >
- Next message: Guadala Harry: "Deleting Multiple Rows"
- Previous message: Anith Sen: "Re: Unlocking a Databse"
- In reply to: Larry Menzin: "Re: T-SQL and OLE Automation"
- Next in thread: Larry Menzin: "Re: T-SQL and OLE Automation"
- Reply: Larry Menzin: "Re: T-SQL and OLE Automation"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|