Showing posts with label batch. Show all posts
Showing posts with label batch. Show all posts

Friday, March 30, 2012

Invoking a batch file from Report

Hi !

I have to invoke a batch file (.bat) when an ad-hoc report is executed. I've currently written a .Net code for invoking (using System.Diagnostics.Process) the batch file. The rdl file calls the method.

When I run the report from Report Designer the batch file is getting executed. But if I deploy it in the Reporting Server and run the report through Web Interface the batch file is not getting executed.

Looks like some security issue. Can someone provide a solution for this?

Thanks.

Where did you place the batch file ? All commands executed either in Script or custom code or executed on the server not on the client.

Jens K. Suessmeyer.


http://www.sqlserver2005.de

|||Just a suggestion on how to execute the .bat file. Could′t you use a SQL Agent job instead and call sp_start_job from a dataset in the report?|||

Hi Jens,

Thanks for the reply.

I placed the batch file in the server. I also moved the code (to invoke a batch file using System.Diagnostics.Process class) to a VB.Net dll and tried invoking the function from the rdl. The function is not getting invoked. I also added SecurityPermissionAttribute to the class. Is there any other Security permission that needs to be added for the code to be accessed.

Please find below the sample:

Public Shared Function fnRunSPX(ByVal x As String, ByVal y As String, ByVal z As String, ByVal w As String)

Dim Pro As New System.Diagnostics.Process

Dim Elog As New System.Diagnostics.EventLog

If Not Elog.SourceExists("BillingDateBatch") Then

Elog.CreateEventSource("BillingDateBatch", "Application")

End If

Dim EventLog1 As New System.Diagnostics.EventLog

EventLog1.Source = "BillingDateBatch"

EventLog1.Log = "Application"

EventLog1.WriteEntry("Success", System.Diagnostics.EventLogEntryType.SuccessAudit)

Pro.StartInfo.FileName = "C:\\batch.bat"

Pro.StartInfo.Arguments = x + " " + y + " " + z + " " + w

Pro.Start()

Pro.WaitForExit()

End Function

Even the evenlogging (present in teh above code) does not happen. Please let me know if you have any questions.

Thanks,

Aravind

Invoking or sending SQL queries using dOS

Hello Folks,
I want to create a simple batch DOS script to query mi SQL Server 2000 database. How I could do this?
I just want to run a select for a table but I dont want people to interct with sql query analyzer or enterprise manager to avoid any issues.
Regards,Look up OSQL or ISQL in Books Online.

Basically:
OSQL -S <name of your server/instance> -U <UID> -P <PWD> -d <Database to use> -Q"<your select statment>" -n -b

I do this all the time so post back if you have more questions.|||Originally posted by Paul Young
Look up OSQL or ISQL in Books Online.

Basically:
OSQL -S <name of your server/instance> -U <UID> -P <PWD> -d <Database to use> -Q"<your select statment>" -n -b

I do this all the time so post back if you have more questions.

UID stands for? PWD I assume is the pasword, isnt.

How I can redirect the results to a txt file,

OSQL -S OSQL -S <name of your server/instance> -U <UID> -P <PWD> -d <Database to use> -Q"<your select statment>" -n -b >> query.txt

Am I right?

Thanks for your prompt reply and help|||UID = User ID

You could pipe the output to a text file but the -o parm would be more usefull.|||How I can get the instance name. I have tested in my environment and I got the next error:

[DBNETLIB] Sql Server does not exist or access denied
[DBNETLIB] ConnectionOpen <Connect(())

As per this result I checked the server name I used typing osql -L. I got the names and used them but with the same result.

When I open the Sql query analyzer I connect using windows authentication option to connect to my databases.

Please suggest..|||For Windows Security I think you need to use -E option instead of -U and -P options.

Tim Ssql