Showing posts with label messagean. Show all posts
Showing posts with label messagean. Show all posts

Tuesday, March 27, 2012

error executing assemblie

hellow i execute assemblie in sql server, assemblie opens up file and writes some information, when i run that esemblie i get the follwing message

An error occured: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

thanks for any ideas

i found solution myself

solution is tu make your assemblie to have external access, but now other error occured when the assemblie is trying to write to file

An error occured: Access to the path 'C:\log.txt' is denied.

(1 row(s) affected)

|||When SQL Server executes something that goes outside of SQL (i.e file access), it does that under the security context of the account SQL runs under. It might be that, that account does not have sufficient permissions for that file.

If that's the case you can (if the original caller uses integrated security) do a impersonation, by using SqlContext.WindowsIdentity.

Niels

Sunday, February 19, 2012

Error automating SQL DTS Pkg from VB6 to VB.Net

I am trying to convert a VB6 SQL 2000 created code into VB.NET. Everything
complies fine but then I get this error message:
An unhandled exception of type 'System.InvalidCastException' occurred in
Project1.exe
Additional information: QueryInterface for interface DTS.CustomTask failed.
This is the portion of the code that it is breaking on:
I found 2 ways to do this but both ways are giving me the same error message
Way #1:
Public Sub Task_Sub1(ByVal goPackage As DTS.Package2)
Dim oTask As DTS.Task
Dim oLookup As DTS.Lookup
Dim oCustomTask1 As DTS.DataPumpTask2
oTask = CType(goPackage, DTS.Package2).Tasks.New("DTSDataPumpTask")
oTask = goPackage.Tasks.New("DTSDataPumpTask")
oCustomTask1 = oTask.CustomTask
Way #2:
Public Sub Task_Sub1(ByVal goPackage As Object)
Dim oTask As DTS.Task
Dim oLookup As DTS.Lookup
Dim oCustomTask1 As DTS.DataPumpTask2
oTask = CType(goPackage, DTS.Package2).Tasks.New("DTSDataPumpTask")
oCustomTask1 = oTask.CustomTask
If anyone has an idea on what I need to change in the code I would greatly
appreciate it.
Thanks in advanceJohn,
Try with this excellent article from Gert Drapers:
http://www.sqldev.net/dts/DotNETCookBook.htm.
Dejan Sarka, SQL Server MVP
Mentor
www.SolidQualityLearning.com
"John" <John@.discussions.microsoft.com> wrote in message
news:B830B251-9289-4510-9ED8-6165AB2A0B92@.microsoft.com...
>I am trying to convert a VB6 SQL 2000 created code into VB.NET. Everything
> complies fine but then I get this error message:
> An unhandled exception of type 'System.InvalidCastException' occurred in
> Project1.exe
> Additional information: QueryInterface for interface DTS.CustomTask
> failed.
> This is the portion of the code that it is breaking on:
> I found 2 ways to do this but both ways are giving me the same error
> message
> Way #1:
> Public Sub Task_Sub1(ByVal goPackage As DTS.Package2)
> Dim oTask As DTS.Task
> Dim oLookup As DTS.Lookup
> Dim oCustomTask1 As DTS.DataPumpTask2
> oTask = CType(goPackage, DTS.Package2).Tasks.New("DTSDataPumpTask")
> oTask = goPackage.Tasks.New("DTSDataPumpTask")
> oCustomTask1 = oTask.CustomTask
> Way #2:
> Public Sub Task_Sub1(ByVal goPackage As Object)
> Dim oTask As DTS.Task
> Dim oLookup As DTS.Lookup
> Dim oCustomTask1 As DTS.DataPumpTask2
> oTask = CType(goPackage, DTS.Package2).Tasks.New("DTSDataPumpTask")
> oCustomTask1 = oTask.CustomTask
> If anyone has an idea on what I need to change in the code I would greatly
> appreciate it.
> Thanks in advance
>