Re: T-SQL and OLE Automation
From: Larry Menzin (LarryMenzin_at_discussions.microsoft.com)
Date: 08/16/04
- Next message: Jason Harmon: "Access to Inserted and Updated from Bound Connection"
- Previous message: Joe Celko: "Re: Nested select"
- In reply to: Greg Linwood: "Re: T-SQL and OLE Automation"
- Next in thread: Greg Linwood: "Re: T-SQL and OLE Automation"
- Reply: Greg Linwood: "Re: T-SQL and OLE Automation"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 16 Aug 2004 15:09:04 -0700
Greg,
Thanks for the help. I am a bit new at this. My current effort involves
verifying byte counts of text files to be used in an ETL process. My simplest
task would be to pass a directory path/filename to a VB ActiveX.EXE using
T-SQL and to return the byte count of the file via (Windows API?) back to SQL
server to store in a table. I usually find sample code on MSDN for most
things, but perhaps this will be a little more difficult!
Thanks,
Larry
"Greg Linwood" wrote:
> 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: Jason Harmon: "Access to Inserted and Updated from Bound Connection"
- Previous message: Joe Celko: "Re: Nested select"
- In reply to: Greg Linwood: "Re: T-SQL and OLE Automation"
- Next in thread: Greg Linwood: "Re: T-SQL and OLE Automation"
- Reply: Greg Linwood: "Re: T-SQL and OLE Automation"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|