If you do DTS in C #, please pay attention!

xiaoxiao2021-03-06  40

The following code is called DTS's way:

DTS.Package2Class Package = new dts.package2class ();

Try

{

Object mia = system.reflection.Missing.Value;

Package.LoadFromsql Server ("(local),

"sa", "000", dts.dtsqlserverStorageFlags.dtsqlstgflag_default, "", "",

"", "Test", ref mia;

Package.execute ();

}

Catch (Exception EX)

{

Throw EX;

}

Finally

{

Package.unInitialize ();

Package = NULL;

}

The above program is written in the WinForm.exe project, there is no problem, but how to write in ASP.NET or WebService, there is a problem. The latter must increase the user login privilege of MachineName / ASPNET in SQL Server and set the DB_OWNER permission that must be accessed for the account, otherwise it will not be called.

Note that it is not a MACHINENAME / ASPNET account on Windows 2003, which is NT Authority / Network Service. Is it very strange? nausea? I don't know why it will be changed to this. It doesn't matter. You can use this method in the program to get the current account of the current ASP.NET: context.Response.write (System.Security.PrinciPal.Windowsidentity.getCurrent (). Name);

Also available

Http://tech.ccidnet.com/pub/Article/c1111_a76467_p1.html Description.

I think this is the problem of the permissions set. I don't know why, I am not clear, because the code has been clearly specified in the way in SA, if anyone can make it clear, please reply.

转载请注明原文地址:https://www.9cbs.com/read-77089.html

New Post(0)