.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Execute DOS Command with Variable

Posted By:      Posted Date: October 08, 2010    Points: 0   Category :Sql Server


I am using 2 task in control flow.

1st task is a "execute SQL task" which returning from DB into a variable called VAR1(i.e. VAR1 = C:\test_data\)

2nd task is "execute process task" where I wnat to delete all the files from the directory (i.e. value got in VAR1)

Pls help.

Many Thanks,





View Complete Post

More Related Resource Links

can't execute "create table" command with Visual Web Developer express

I have a folder with a web site I'm developing which is connected to a database.Every time I move the folder to a different computer it's a pain when I have to move the database and change the connection string.I've thought to use for the first time a database in the app_data folder and move all the database inside it.Nevertheless, when I try to recreate all the tables in the new database for the first time with the query "create table ..." I get and error saying that "SQL CREATE TABLE" is not supported.Is there a way to manage this situation?--   Giuseppe

Execute Command and wait until finished (WMI - ManagementClass)

Hi allI am trying to execute a command on a remote maschineand wait until the command is finished.I can start the process but I do not know how to wait for finish.Thanks for any comment !!!Best regardsFrankHere is what I am doing            System.Management.ConnectionOptions local_Connection = new System.Management.ConnectionOptions();            local_Connection.Username = "some_user";            local_Connection.Password = "some_password";            local_Connection.Authority = "ntlmdomainome_domain";            // ManagementScope erstellen            System.Management.ManagementScope local_Scope = new System.Management.ManagementScope("\\\\servername\\root\\CIMV2", local_Connection);            local_Scope.Connect();            // ManagementClass erstellen            System.Management.ManagementClass local_ClassInstance = new System.Management.ManagementClass(local_Scope, new System.Management.ManagementPath("Win32_Process"), null);            // Create a results and completion handler            System.Management.ManagementOperationObserver local_ClassHandler = new System.Management.ManagementOperationObserver();            // Invoke method asynchronously            System.Management.ManagementBaseObject local_InParams = local_ClassInstance.GetMethodParameters("Create");            local_InParams["CommandLin

Using a Variable in SSIS - Error - "Command text was not set for the command object.".

Hi All, i am using a OLE DB Source in my dataflow component and want to select rows from the source based on the Name I enter during execution time. I have created two variables, enterName - String packageLevel (will store the name I enter) myVar - String packageLevel. (to store the query) I am assigning this query to the myVar variable, "Select * from db.Users where (UsrName =  " + @[User::enterName] + " )" Now in the OLE Db source, I have selected as Sql Command from Variable, and I am getting the variable, enterName,. I select that and when I click on OK am getting this error.   Error at Data Flow Task [OLE DB Source [1]]: An OLE DB error has occurred. Error code: 0x80040E0C.An OLE DB record is available.  Source: "Microsoft SQL Native Client"  Hresult: 0x80040E0C  Description: "Command text was not set for the command object.". Can Someone guide me whr am going wrong? myVar variable, i have set the ExecuteAsExpression  Property to true too. Please let me know where am going wrong? Thanks in advance.

ListView.ItemTemplate with Button. Command doesn't execute when item is selected

I have a listview with an item template that contains a button: <ListView ItemsSource="{Binding AllProducts}"> <ListView.ItemTemplate> <DataTemplate> <Grid> <Button Content="Add Supplier" Command="{Binding AddSupplier}"/> </Grid> </DataTemplate> </ListView.ItemTemplate> </ListView> When the listitem is not selected and the button is clicked, the command executes fine. However, if the listitem is selected, the command does not execute. I have tried putting click and mouse down event handlers on the button, but the events do not fire. Is there any way to make the command execute when the listitem is selected?

SQL Command Or Stored Procedure in Execute SQL Task


Hi all,

Which is a better way to do in Execute SQL Task : Direct SQL input or Create a stored proc in database and then use that.

In my opinion, Stored Procedure is a better and recommended way for following reasons:

  • Cached execution plan
  • More secure
  • Centralized code
  • Code reuse

Please let me know if this is not the case with SSIS Execute SQL Task.


The data source control failed to execute the insert command


Hi All,

I have create table in SQL 2005 and retrive its data in to sharepoint  with the help of Database connection option through Sharepoint Designer. When configuring the connection i have selected a custom quer with stored procedure option and from the dropdown option selected the insert stored procedure everything is ok.

Stored Procedure
CREATE PROCEDURE ChangeTable_insert

 @PROJECT varchar(50) ,

INSERT INTO [dbo].[ChangeTable]





i have created new aspx page in Sharepoint Designer from the datasource details-->Insert selected fields as-->selected new item form and saved this page.
When i opened this page in to browser and try to save data it gives an below error
Go back to site 
Error: "The data source control failed to execute the insert command.
 Troubleshoot issues with Windows SharePoint Services."

please help me. i have to save data to sql database through sharepoint

thanks in advance

Execute SQL Tast output into a Variable in SSIS




I´m trying to put the count or the max value of an slq statement in to a variable and I´m not able until now.


I have a global variable named vMax and a OLE DB connection to a DB.

The Quiery works fine and a get a result depending of Count or Max from 15000 for Count and 2000849400 for Max.


I tried all Variable types as int16, int32, double,... nothing works and I get allways the same error mesage.


Error: 0xC001F009 at xyz: The type of the value being assigned to variable "User::vMax" differs from the current variable type. Variables may not change type during execution. Variable types are strict, except for variables of type Object.


I tried now everything and I was not able I have now only this execute SQL Task in my project and it does not work.


My goal is to copy all new records from Table1 in to Table2.

So I create an Execute SQL Tast to get the max ID and to use this for a sql command in the OLE DB Source.


Thank you in advance for any help.




Addition:  _____________________________________________________________________________

Im still trying to get this work and found one thing out. The ID that I'm using to find the Ma

need to store the value of Execute SQL(dynamic sql) into variable.


Hi guys, I need to store the value of my dynamic sql query into a variable

Basically i am passing a table name and then doing a count(*) to get the number of rows but having difficulty in storing the value of the Exec(@sql) into a variable.

Pls help


Select @sql = 'Select' + CAST(@TRCnt AS Varchar) + ' = count(*) From [' + @TTableName  + ']'



OLE DB Destination SQL command - how can I select from recordset variable?


How do I insert records from connection1 into a a table with the same name on connection2 where the records in connection2 do not already exist?

The approach I'm trying is this: I have an OLE DB Source that selects records from connection1 (successfully). The flow into a recordset destination in the Data Flow. But I can't figure out how to select from this recordset using the FROM CLAUSE of a SQL Command in the OLE DB Destination component. Can someone point me to an example of this?

It seems like this would be a common task but I can't find any examples.

Using MVVM and commands inside of a datatemplate, the command wont execute.

Inside of my main view i have a datatemplate showing off all the items in an observable collection. now inside of that i want to set commanding on a radio button.

outside the datatemplate this works
<Button Height="23" Name="btnUpdate" Command="{Binding UpdateCommand}"

The data source control failed to execute the insert command


In SharePoint Designer 2007 I'm trying to customize the edit form that you get when you create a list item in a SharePoint 2007 list (EditForm.aspx). I took the following steps:

1.       Open the site in SharePoint Designer 2007.

2.       Browse to the list and open the 'NewForm.aspx' web form.


Cannot execute a program. The command being executed was "c:\WINDOWS\Microsoft.NET\Framework\v3.5\cs


The webserive is throwing the following exception every time unless I reset iis. I don't think it is machine dependent as it is happening on other machines. There is some fix for asian version and I don't think I have asian version (conime). but I tried it anyway but doesn't work. The error clears by restarting IIS on development but that is not a solution for webserver. Does anybody know how to resolve this issue? It's not memory issue as I have plenty of free memory.

ExternalException (0x10b): Cannot execute a program. The command being executed was "c:\WINDOWS\Microsoft.NET\Framework\v3.5\csc.exe" /noconfig /fullpaths @"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\fi_firtkservice\5e540d70\ff1820cc\nitishj0.cmdline".]
   System.CodeDom.Compiler.Executor.ExecWaitWithCaptureUnimpersonated(SafeUserTokenHandle userToken, String cmd, String currentDir, TempFileCollection tempFiles, String& outputName, String& errorName, String trueCmdLine) +2204
   System.CodeDom.Compiler.Executor.ExecWaitWithCapture(SafeUserTokenHandle userToken, String cmd, String currentDir, TempFileCollection tempFiles, String& outputName, String& errorName, String trueCmdLine) +122
   Microsoft.CSharp.CSharpCodeGenerator.Compile(CompilerParameters options, String compilerDi

"The data source control failed to execute the insert command." when inserting to sql table with tri



I have a data view web part that inserts a new record into a sql table. This works fine.

I have now needed to add a trigger to the sql table that sends an email when a new record is inserted (the code for which works fine) but now my insert fails with 'The data source control failed to execute the insert command.'.

If I disable the trigger the form works fine again.

Any ideas what could be causing this?


Copying rows using a dynamic SQL Command variable


I have a table with the Source TableName and Source ColumnName. I am trying to use SSIS to extract data from my source based on the tables and columns. I am using a Script Task to dynamically create the SELECT statement, no problems with that.

Next, I have a data flow task with a Source OLE DB Connection and the Data Access mode is using this dynamically created select statement. I am however unable to use this because this SELECT statement variable is not populated until runtime.

Basically I want to COPY ALL ROWS from the source to a destination. 

Is this possible? What is wrong with my assumptions? Any suggestions?


You are so wise...like a miniature budha covered in fur. -Anchorman

pass datetime variable into execute sql task which has stored procedure


Hi all

I have a stored procedure something like this exec sp_name startdate, enddate. I have to run this in an ssis package.

The startdate and enddate values are loaded from a sql query, so i have declared variables (startdate,enddate) and got those values from the query using evaluateasexpression. Now, when i call the stored procedure in execute sql task it fails as the datatype from the variable is string and the stored procedure parameter (startdate,enddate) are datetime. Please help me.

The following are my settings in execute sql task editor

SQL statement : EXEC sp_name ?,?

parameter mapping

variablename: user::startdate

Direction: Input

data Type: Date

Parameter name : 0

Parameter size : -1


how to execute a command on gridview row click???


i have two gridviews in my page..gridviewCart to display the items in the cart and gridviewStore to display the list of stores a particular item is available in.


now what i want is....when the user clicks on a row in gridviewCart...i want to dynamically show the list of stores in gridviewStore.


Eg. in gridviewCart row number one has the item Samsung Galaxy...so when a user clicks on row number one i want to show the list of shops whis has Samsung galaxy in gridviewStore.


is there any way to do this??


Local variable scoping in C#

In my previous post, Compiler-generated scopes for local variable declarations, I briefly touched on the issue of multiple meanings applied to the same name. In this post, I'll aim to flush out the compiler's rules with regards to binding names in their local scopes.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend