Showing posts with label connect. Show all posts
Showing posts with label connect. Show all posts

Tuesday, March 20, 2012

Calling DTS from ASP throught ISA Firewall

I am trying to execute a DTS package from our external web site. The package resides on an SQL Server inside the ISA firewall. I can connect to the SQL Server via ADO but everything else is blocked so the following code will not work since I believe it uses Windows Integrated Security:

Dim oPkg
Dim objCID
Dim objSID
Dim objOrderID

Set oPkg = CreateObject("DTS.Package")

Set objCID = oPkg.GlobalVariables.New("@.CID")
Set objSID = oPkg.GlobalVariables.New("@.SID")
Set objOrderID = oPkg.GlobalVariables.New("@.OrderID")

oPkg.LoadFromSQLServer "ServerName", "UserName", "Password", , , , , "MSIOrder"

objCID.Value = "2303"
objSID.Value = "822105614"
objOrderID.Value = "323"
oPkg.GlobalVariables.Add objCID
oPkg.GlobalVariables.Add objSID
oPkg.GlobalVariables.Add objOrderID

oPkg.Execute
Set oPkg = Nothing

Is there a way to call this DTS package via an ADO connection? And of course, to complicate things, I need to pass the DTS package three global variables.

Lastly, modifying the ISA config is not an option unless I can be absolutely sure that it would not alter our current level of security.

Thanks in advance,
JimDTS? Ick. Anyway, are you sure you have the DTS DLLs installed on the client machine (this case the web server)? I believe you need to install Enterprise Manager on the machine for those DLLs to get installed. No separate installation as far as I know.

Also, what error message are you getting?
~Mattsql

calling another server connection through a stored procedure

anybody have an idea how to call a server through a stored procedure...

ex)
from my asp, i connect to sql server then call a stored procedure...in the stored procedure i want to connect to a remote database (jdedwards) and bring back tables to use in that procedure that eventually is used for output.

how do you make the connection to jde?You can do it through either linked server or remote server. Either way, you need to register the 2nd server on the first server. Provided permision is granted, you then run query in the 'select * from serverName.dbName.owner.tableName' format.|||thanks!

but now HOW DO I register my sql server to connect to a non Sql Server....the only way I can connect to the other Database is through ODBC? In other words, I need my sql server's stored procedure to ODBC to a non SQL server; i.e., AS/400.

Sunday, March 11, 2012

Calling a Dts package from VB.NET

hi,

i'm trying to call a dts package from vb.net.

i got 2 examples which both don't work.

first one gives me a [DBNETLIB][ConnectionOpen(Connect()).]SQL Server does not exist or access denied error.

source code:
Dim serverName As String = "SERVERNAME"
Dim oPackage As New DTS.Package()
Dim oStep As DTS.Step
Dim pVarPersistStgOfHost As Object = Nothing

oPackage.LoadFromSQLServer(serverName, "USERID", "PASSWORD",
DTSSQLServerStorageFlags.DTSSQLStgFlag_Default, _
"DTSPASSWORD", Nothing, Nothing, "DTSPACKAGENAME", pVarPersistStgOfHost)

For Each oStep In oPackage.Steps
oStep.ExecuteInMainThread = True
Next

oPackage.Execute()

Dim err As Long
Dim source, description, message As String
For Each oStep In oPackage.Steps
If oStep.ExecutionResult = DTSStepExecResult.DTSStepExecResult_Failure Then
oStep.GetExecutionErrorInfo(err, source, description)
message = String.Format("ErrorCode: {0}, Source: {1}, Description: {2}", err.ToString(), source,
description)
Else
message = "Success"
End If
Next

oPackage.UnInitialize()
oPackage = Nothing

second example tries to create a dts package dynamically. this time i get the error that the CustomTask can not be casted, somehting about the QueryInterface.

source code:
Dim oPackage As New Package2()
Dim oConnection As Connection2
Dim oStep As Step2
Dim oTask As Task
Dim oCustomTask As BulkInsertTask


oConnection = oPackage.Connections.[New]("SQLOLEDB")
oStep = oPackage.Steps.[New]()
oTask = oPackage.Tasks.[New]("DTSBulkInsertTask")
oCustomTask = CType(oTask.CustomTask, BulkInsertTask) <-- error

With oConnection
.Catalog = "CATALOG"
.DataSource = "SERVERNAME"
.ID = 1
.UseTrustedConnection = True
.UserID = "USERID"
.Password = "PASSWORD"
End With

oPackage.Connections.Add(oConnection)
oConnection = Nothing

With oStep
.Name = "InsertGemal"
.ExecuteInMainThread = True
End With

With oCustomTask
.Name = "InsertGemal"
.DataFile = "D:\ImportGemal.dat"
.ConnectionID = 1
.DestinationTableName = "Gemal"
.FieldTerminator = ";"
.RowTerminator = "\r\n"
End With

oStep.TaskName = oCustomTask.Name

With oPackage
.Steps.Add(oStep)
.Tasks.Add(oTask)
.FailOnError = True
End With

oPackage.Execute()

oPackage.UnInitialize()
oPackage = Nothing

any help highly appreciated!

t.i.a.,
ratjetoes.

Then you need to use xp_cmdshell by granting a proxy account for SQL Server Agent the right permissions to run the package through Asp.net. The links below covers the extended stored proc xp_cmdshell and the proxy account. One more thing the DTS site is run by a DTS expert there are many resources you could use. Post again if you have more questions. Hope this helps.

http://forums.asp.net/thread/1440879.aspx

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_xp_aa-sz_8sdm.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_xp_aa-sz_4jxo.asp

|||

tnx 4 your help,

it was indeed somehting with permission rights.

i got it working now.

ratjetoes.

|||

ratjetoes:

tnx 4 your help,

it was indeed somehting with permission rights.

i got it working now.

ratjetoes.

I am glad I could.

Thursday, March 8, 2012

Callable statements, SQLServer and JRun

Hi,

I'm developing a java application which uses SQL Server as the
database. I use Callable Statements to connect to the database. I use
JRun as the app server. When
running the application I want to be able to monitor locks/process
info etc in the 'Current Activity' section in the 'Management'
section
in SQL Server.

The problem is that at the moment if I look at the 'Last TSQL command
batch' in the process or lock, it does not display the sql for the
current call. It displays what seems to be the precompiled call:
#jdbc#9;1

Anyone know how to get it to display the sql?

Is it a driver issue or is there a SQL Server setting to get it to do
this?

Thanks(cormac.foley@.gmail.com) writes:

Quote:

Originally Posted by

I'm developing a java application which uses SQL Server as the
database. I use Callable Statements to connect to the database. I use
JRun as the app server. When
running the application I want to be able to monitor locks/process
info etc in the 'Current Activity' section in the 'Management'
section
in SQL Server.
>
>
The problem is that at the moment if I look at the 'Last TSQL command
batch' in the process or lock, it does not display the sql for the
current call. It displays what seems to be the precompiled call:
#jdbc#9;1
>
>
Anyone know how to get it to display the sql?
>
>
Is it a driver issue or is there a SQL Server setting to get it to do
this?


Didn't you ask the same question a week ago or two? Yes, that was
another newsgroup, but at least you should have learnt by now that it
is a driver issue. And I hope that you should know that you should
use parameterised statements.

Well, I see on Google Groups that you also have posted your
question to comp.lang.java.programmer. Too that you did not cross-post.
It would have been interesting to see the answers from the Java folks.

--
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|||On Feb 12, 10:29 pm, Erland Sommarskog <esq...@.sommarskog.sewrote:

Quote:

Originally Posted by

(cormac.fo...@.gmail.com) writes:

Quote:

Originally Posted by

I'm developing a java application which uses SQL Server as the
database. I use Callable Statements to connect to the database. I use
JRun as the app server. When
running the application I want to be able to monitor locks/process
info etc in the 'Current Activity' section in the 'Management'
section
in SQL Server.


>

Quote:

Originally Posted by

The problem is that at the moment if I look at the 'Last TSQL command
batch' in the process or lock, it does not display the sql for the
current call. It displays what seems to be the precompiled call:
#jdbc#9;1


>

Quote:

Originally Posted by

Anyone know how to get it to display the sql?


>

Quote:

Originally Posted by

Is it a driver issue or is there a SQL Server setting to get it to do
this?


>
Didn't you ask the same question a week ago or two? Yes, that was
another newsgroup, but at least you should have learnt by now that it
is a driver issue. And I hope that you should know that you should
use parameterised statements.
>
Well, I see on Google Groups that you also have posted your
question to comp.lang.java.programmer. Too that you did not cross-post.
It would have been interesting to see the answers from the Java folks.
>
--
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- Hide quoted text -
>
- Show quoted text -


He he..u the newsgroup police or something? Yes I asked the same
question last week on Yahoo. Am interested in getting numerous
opinions on this.

I have tried a number of different types of driver and all of them
still result in the compiled sql in the 'Last TSQL command batch'
value. Interestingly when I use Microsoft drivers they seem to compile
everything..and Macromedia drivers just seem to compile stored
procedure calls which have parameters.

I need to use stored procedures/CallableStatements - it may be that is
not possible to have the uncompiled sql available in the log when
using CallableStatements no matter what driver I use.

Wednesday, March 7, 2012

Call SSIS remotely to run exe task in server by C#

I would like to build a C# program to connect to a remote SQL2005 server.

Then call the server SSIS to run a .exe in the server (The .exe file already exist in the SQL2005 server)

I have refer to the following webpage http://www.codeproject.com/useritems/CallSSISFromCSharp.asp

I can connect to the SQL server by the "LoadFromSqlServer" method with SQL server login A/C.

However, the SSIS failed. I believe it should be due to the window authentication issue. During SSIS execution, the SQL server login A/C does not have the access right to run the .exe file

Could anyone suggest the solution?

Thanks.

If you are running the C# executable on your computer, it is not running the SSIS package on the server,it is executing it locally. So it would be running under your account, or it may be that the .exe on the server is not visible from your computer.

To actually run the package locally on the server, you'd need to create a web service, or use SQL Agent to run the package. This post from Michael Entin has more details: http://blogs.msdn.com/michen/archive/2007/03/22/running-ssis-package-programmatically.aspx