Calling a stored procedure remotly

  • Thread starter Thread starter b_viehmann_Aachen
  • Start date Start date
B

b_viehmann_Aachen

Hi,

i want to call a stored procedure remotly on a linked server with ado.net.
What i am doing in ironpython is this:

conn = SqlClient.SqlConnection(connectionString)
conn.Open()

action = SqlClient.SqlCommand("stopro_GetJobStatus", conn)
action.CommandType = CommandType.StoredProcedure

reader = action.ExecuteReader();
while reader.Read():
values = Array.CreateInstance( Object, reader.FieldCount)
reader.GetValues(values)
print(values)
self.results.append(values)

reader.Close()
conn.Close()

But i got an error message:

Traceback (most recent call last):
File "IpsPlusDbWatchDog.py", line 257, in IpsPlusDbWatchDog.py
File "IpsPlusDbWatchDog.py", line 129, in __init__
File "System.Data", line unknown, in ExecuteReader
File "System.Data", line unknown, in ExecuteReader
File "System.Data", line unknown, in RunExecuteReader
File "System.Data", line unknown, in RunExecuteReader
File "System.Data", line unknown, in RunExecuteReaderTds
File "System.Data", line unknown, in FinishExecuteReader
File "System.Data", line unknown, in get_MetaData
File "System.Data", line unknown, in ConsumeMetaData
File "System.Data", line unknown, in Run
File "System.Data", line unknown, in ThrowExceptionAndWarning
File "System.Data", line unknown, in OnError
File "System.Data", line unknown, in OnError
EnvironmentError: Login failed for user 'tasks'.

When I am trying this code with a query instead of a stored procedure
everything works fine.

So is it rigth that i have to change the configuration of the SQL-Server?
How?

BTW: I am using Win2003 Server and SQL-Server 2005.

Thanks much for your help..... :-)
 
Two things you can do:

always put this as first line into the stored proc:

SET NOCOUNT ON

and if you use table variables (i suppose you do if i see the error
message) then this should help:

IF 1 = 0 BEGIN
SET FMTONLY OFF
END

put it on the beginning of your stored proc. I know, normaly something
can't work, but try it...

bye,
Helmut
 
Back
Top