Parameters In Sql Task Sub Query

Oct 9, 2006

DELETE T1
WHERE EXISTS
(SELECT *
FROM T2 A
WHERE A.C1= T1.C1
AND A.C3 >= ?)


Results in below error (OLEDB SQL TASK):

" failed with the following error: "Parameter Information cannot be derived from SQL statements with sub-select queries. Set parameter information before preparing command.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

Any resolution?

View 9 Replies


ADVERTISEMENT

DTS SQL Task Parameters Error

Feb 16, 2006

I have an odd problem with the parameters in a SQL task.

I created a DTS package with an SQL task that uses a parameter marker in the WHERE cause. The value comes from a Global Var. The package runs fine but when I try to access the parameter mapping page I get this:

Syntax Error or Access Violation Error

Anybody know what to do about this?
It's not very efficient to have to rebuild the task every time I need to add a parameter.

Thanks

View 1 Replies View Related

Parameters And Execute SQL Task

Apr 2, 2008

I know you can pass parameters into a Direct Input and a Stored Proc in the Execute SQL Task Editor, but can you pass parameters to a File Connection? If so, then how would I do that?

Thank you,

Steve...

View 5 Replies View Related

Parameters In Execute SQL Task After SP2

Apr 25, 2007

Hi,



we have a Package, that worked fine for a long time. Now, it always fails on all computers with SP2 instaled. The problem apears in execute sql task, which uses ole db connection manager and calls a procedure with some input parameters (from sql server).

Package sends a undesirable data (".") into the procedure from variable, which has NULL or Empty string value. Originaly, data type of the Variable was Object, I tried to use also string, but in both cases the procedure was called with parameter "."



Please, can anybody tell me what's wrong?



Thanks



Janca

View 2 Replies View Related

ExecuteSQL Task With Parameters

Jul 14, 2005

I have an insert statement that i am trying to parameterize based on a variable.  I have tried:

View 23 Replies View Related

SQL Task - Passing Parameters

Feb 20, 2006

Hello,
I have a SQL task wich executes the following statement on a OLEDB connection (SQL 2005 DB):

TRUNCATE TABLE DimTime
GO

DECLARE @CurrentDate AS Datetime
DECLARE @EndDate AS Datetime

SET @CurrentDate = '10-20-2003';
SET @EndDate = '10-20-2005';

while(@CurrentDate < @EndDate)
begin
INSERT INTO DimTime SELECT
DATEPART(month, @CurrentDate) AS MonthNumberOfYear
,DATEPART(quarter, @CurrentDate) AS CalendarQuarter
,DATEPART(year, @CurrentDate) AS CalendarYear
,dbo.GetSemester(DATEPART(month, @CurrentDate)) as CalendarSemester
,DATEPART(quarter, @CurrentDate) AS FiscalQuarter
,DATEPART(year, @CurrentDate) AS FiscalYear
,dbo.GetSemester(DATEPART(month, @CurrentDate)) AS FiscalSelester

set @CurrentDate = dateadd(month, 1, @CurrentDate)
end
GO

Now I want to parametrize the statement creating an external variable:

1. I created a datetime package variable (DimTimeStartDate)

2. Add update the above SQL statement to

SET @CurrentDate = ?;

3. I mapped the package variable to a new parameter (name 0)

Executing I get the following error:

[Execute SQL Task] Error: Executing the query " DECLARE @CurrentDate AS Datetime DECLARE @EndDate AS Datetime SET @CurrentDate = ?; SET @EndDate = '10-20-2005'; while(@CurrentDate < @EndDate) begin INSERT INTO DimTime SELECT DATEPART(month, @CurrentDate) AS MonthNumberOfYear ,DATEPART(quarter, @CurrentDate) AS CalendarQuarter ,DATEPART(year, @CurrentDate) AS CalendarYear ,dbo.GetSemester(DATEPART(month, @CurrentDate)) as CalendarSemester ,DATEPART(quarter, @CurrentDate) AS FiscalQuarter ,DATEPART(year, @CurrentDate) AS FiscalYear ,dbo.GetSemester(DATEPART(month, @CurrentDate)) AS FiscalSelester set @CurrentDate = dateadd(month, 1, @CurrentDate) end " failed with the following error: "Syntax error, permission violation, or other nonspecific error". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

Not clear what is wrong. Any help ?

Thanks,
Pierre

View 12 Replies View Related

DTS Parameters In &#39;execute SQL Task&#39; SQL Server 2k

Jan 8, 2002

Hi

SQL server 2000 DTS Problem

I'm trying to pass the value of a global variable
as an input parameter in a 'execute sql task' DTS object.

However, SQL refuses to accept the global variable
assigned to the input parameter '?'. When you run the
DTS package the error message 'no value given for one or
more parameters' appears.

When you save / exit the DTS object by clicking OK, and then go
back into it, the 'input Global variables'
parameter field is empty again.
Searched msdn/knowledgebase to no avail - please help ! Thanks






Help much appreciated please !

View 6 Replies View Related

Problem Exec SP With Parameters In SQL Task

Jan 12, 2008

Hello,
I am trying to use an Execute SQL Task to execute a stored procedure with parameters in SSIS but it keeps giving me errors, for example I type in 'exec someproc ?, ?, ?' in SQL Task it wouldnt parse correctly and when I set the bypassPrepare to 'true' the package runs but gives me error at the destination saying couldnt find stored procedure 'someProc'.

Does anybody know how I can solve this problem?

Also how do I pass the results of the queries in the Execute SQL Task into the Data Flow Task? The proc is supposed to retrieve data and transform them into XML format to be placed at a XML file. I am not sure if I should used an OLEDB source or an XML source since the data has been transformed into XML. Any help will be greatly appreciated.

View 1 Replies View Related

Execute SQL Task: UDF Not Taking Parameters

Sep 20, 2007

Hi,


I have an Execute SQL Task in my SSIS Package.
Now, this Execute SQL Task has the following query (Connection Type is OLE DB):




Code SnippetSELECT dbo.udf_CommonDateTime_Get (GetDate(), ?) As User_Datetime





I want 2 things from this Task:
1) It should take the 2nd argument to the UDF from a variable.
2) It should store the value returned by this SELECT statement into another variable.


So, I go ahead and modify the Parameter Mapping for the Task. Here I add the Input variable name, Data type and I give the Parameter Name as 0.


I also modify the Result Set for the Task. Here, I specify the Result Name as User_Datetime and give the appropriate Variable Name.


I am getting an error here and I believe it is due to the input parameter. The UDF is not getting the 2nd argument correctly.


My questions:
1) Has the Execute SQL Task been designed to handle UDFs like this. If not, then where am I going wrong?
2) What is the work-around for this? I need to pass a parameter (variable) to the UDF.


Thanks in advance.


Regards,
B@ns

The error message is:



Code Snippet
Execute SQL Task: Executing the query "SELECT dbo.udf_Common_DateTime_Get (GetDate(), ?)
As User_Datetime" failed with the following error: "Syntax error, permission violation, or other nonspecific error". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
Task failed: Set UserDateTime

View 5 Replies View Related

DTS Package: Execute Process Task && Parameters

Jul 27, 2004

Hello,

I have several DTS packages that take data from SQL Server and exports them onto an Access DB located on the network. Basically, one Execute Process Task from within my DTS package takes the Access DB and zips it while another such task copies the zipped DB and pastes it onto another location on the network. All this works fine.

This export process happens once a month so each month I have to manually add a datestamp to the end of the Access DB file that’s being exported to distinguish it from prior month's export. For example, this month's export file would have AccessDB_20040727.mdb name and the next month it would be AccessDB_20040820.mdb (date is determined based on the date the output is exported on). AccessDB.mdb is the default name of the export DB and datestamp is added at the end of the file name depending on what date the export was run. As I said, I can do this manually each month and it works fine.

I want to, however, know if there is a way to automatically supply the datestamp to the Execute Process Task's Parameters' text box? Following is what I have right now in the Parameters box:
\ghf1-ndc8-sqll$productionoutputlob200406LOB_CF_forDril ldown_All_20040727.zip \ghf1-ndc8-sqll$productionoutputlob200406LOB_CF_forDril ldown_All.mdb

I want to take above text from the parameters box and replace it with something like:
\ghf1-ndc8-sqll$productionoutputlob200406FileName_RunDa te.zip \ghf1-ndc8-sqll$productionoutputlob200406LOB_CF_forDril ldown_All.mdb

Where FileName_RunDate is a variable/placeholder for the name of the output with the datestamp the output is exported on.

There are three different Execute Process Tasks that are happening within each of my DTS packages so it's a time consuming job to have to manually add a datestamp to each package every month when data is exported.

Does anyone know if what I am asking is doable? If I can use a variable in the parameters box of each Execute Process Task’s properties and supply current datestamp values to it prior to executing the package each month? If so then what are the ways? How would I do that?

Thanks much.

JN

View 2 Replies View Related

Using Package Variables As Parameters In Execute Sql Task

Feb 23, 2006

Hi,

I need to run an SQL command, in which one of the fields is based on the current time, represented as a string in a specific format.

I used a script task to create the string from the current time, and store it in a package variable named "newDate". Later, in the execute sql task, I have the following update statement: "update table_1 set field_1 = ?" (OLE DB connection is used)

and in the parameters mapping I set parameter 0 to the string package variable "newDate".

The problem is that on runtime, the sql executes with the default value of the variable - i.e. it doesn't take the new value.

I checked it and placed another script task after the first one, that simply tries to read the variable "newDate" and print it to screen, but even here the default value is used.

how can I use the new value of the variable?

thanks.

View 7 Replies View Related

SSIS Web Service Task Input Parameters

Nov 7, 2006

There is not a way to pass parameters to input of Web Service tasks. I heard this problem is fixed with SQL2K5 SP1 and even the online doc says that one can choose either "value" or "variable" when specifying input for web service tasks, but after I installed what-I-think-is SP1, there is still no way to do this.

If one can only specify values (hard-coded) as input to web service tasks, then this would be a very severe limitation. I hope I'm wrong, so could someone please give a pointer. Thanks

Kevin Le

View 7 Replies View Related

How To Pass Parameters Into Data Flow Task

Jul 18, 2007

I have a DTS package of SQL server 2000 which has two "Execute SQL Task", which gets maximum ID (call it maxID1) from table1 in mysql and maximum ID (call it maxID2) from table 2 in sql server. Those 2 as global variables passes into a data flow which grabs all data from mysql's table1 with its ID > maxID2 and ID <= maxID1 and insert into SQL server table3. This package is working so far.



My question is how to achieve the same thing in SSIS? I created two "Execute SQL Task", which will get maxID1 and maxID2, and one "Data Flow Task". But how to pass those 2 parameters into that "Data Flow Task" without using "Script Task"?



Anyone could help? Thanks!

View 4 Replies View Related

Query Duration Using Parameters Vrs No Parameters

Apr 27, 2006

Hi,
I have an app in C# that executes a query using SQLCommand and parameters and is taking too much time to execute.

I open a SQLProfiler and this is what I have :

exec sp_executesql N' SELECT TranDateTime ... WHERE CustomerId = @CustomerId',
N'@CustomerId nvarchar(4000)', @CustomerId = N'11111

I ran the same query directly from Query Analyzer and take the same amount of time to execute (about 8 seconds)

I decided to take the parameters out and concatenate the value and it takes less than 2 second to execute.

Here it comes the first question...
Why does using parameters takes way too much time more than not using parameters?

Then, I decided to move the query to a Stored Procedure and it executes in a snap too.
The only problem I have using a SP is that the query can receive more than 1 parameter and up to 5 parameters, which is easy to build in the application but not in the SP

I usually do it something like
(@CustomerId is null or CustomerId = @CustomerId) but it generate a table scan and with a table with a few mills of records is not a good idea to have such scan.

Is there a way to handle "dynamic parameters" in a efficient way???

View 1 Replies View Related

Executing Stored Procedure With Parameters Using Execute Sql Task

Jul 12, 2006



Hi ,

I am trying to exectue a stored procedure through execute sql task which takes two input parameters table name and filegroup to create a table and it also returns a value.

i am using the oledb connection

but i am getting the following error



[Execute SQL Task] Error: Executing the query "declare @rtn_value int exec spm_Utopia_FinanceUsage_Create_MonthlyTable ?,? select @rtn_value as rtn_value " failed with the following error: "Syntax error or access violation". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.



i tried with ado.net connection by directly giving the parameter names.

it will create a table but the the table name is something different from what i specified



Please do help as soon as possible



Thanks

Manish



View 2 Replies View Related

Why Doesn't The Execute Package Task Support Parameters?

Aug 29, 2007



[Microsoft follow-up]

dtexec.exe allows us to pass values into a package using /SET and a property path. Why can't we do the same using the Execute Package Task?

And yes, I know about Parent Package Configurations, I use them alot. But I would still like the ability to pass values in.

-Jamie

View 11 Replies View Related

Passing Parameters To SSIS Execute Process Task

Feb 20, 2008

Hi

Can anyone help me in for the following.

i want to execute a exe file with two variable parameters

Executable : C: empMyExe.exe
Parameter1 : User::Category type is string (below example A)
Parameter2 : User::Amount type is string (below example 1)

in dos it looks like this
c: empMyExe A 1

This will executes fine.

Thanks,
Madhu

View 1 Replies View Related

Dynamically Changing Web Service Task Parameters At Runtime?...

Aug 15, 2005

Okay, this one might stump you guys.

View 3 Replies View Related

Execute SQL Task Passing Parameters To A Restore Command

Mar 22, 2007

Hi,

I'm very new to SSIS and I€™m trying to do the following in a SQL task

RESTORE DATABASE @DatabaseName FROM DISK = @Backup WITH FILE = 1, MOVE @OldMDFName TO @NewMDFPath, MOVE @OldLDFName TO @NewLDFPath, NOUNLOAD, REPLACE, STATS = 10

I'm using an OLE DB connection and I have mapped user variables to the various parameter names. Unfortunately when i test the above command it fails on must declare the scalar variable "@DatabaseName". How can i get my values to be substituted into the command?

Many thanks

Martin



View 4 Replies View Related

Multi-parameters Issue In Data Flow Task SSIS

Dec 4, 2006

Hi all,

I met a problem when trying to pass values to a SQL statement through parameters. It's a data flow task. I used the OLE DB connection. My statement is like the statement below(the real statement is little complex):

Select * from myTable where mydate>? and mydate<?

I used the "set query parameter" dialogbox to bulid two parameters varStartTime and varEndTime, the values for the two parameters were set to "1/1/2005" and "12/30/2006" respectively. But when I click the "Parse query" button, I got errors

Parameter Information cannot be derived from SQL statements. Set parameter information before preparing command.

I have referred to the posts, but the problem still exists. Any help will be highly appreciated. Thanks a lot!

View 1 Replies View Related

How To Pass Values To A Stored Procedure Parameters By Using Script Task

Nov 27, 2007



Hi All,

I have One package that it contains one Execute SQL task in that i have placed a Stored procedure .
Now i want to pass values to Stored procedure parameters from a databse table by dynamically .For this i am trying to use " Script task "
How can i pass that table column values to that stores procedure thru using Script Task?

Regards,
Maruthi..

View 3 Replies View Related

Problems In Mapping Parameters Of Type Int64 To The Execute SQL Task

Dec 31, 2007

Good day everyone,


I have a question concerning the Execute SQL task.


Problem Statement:
I have a table containing the following sample data.


Catalog_ID, Product_ID, IsBlocked
56789, 1, 0
56789, 3, 1
23567, 1, 0
23567, 2, 1


The data types of the fields are:
Catalog_ID: bigint
Product_ID: bigint
IsBlocked: bit


I have two variables called "old_catalog_id" and "new_catalog_id" with the following values:
old_catalog_id: 56789
new_catalog_id: 11111


Now, I would like to select all the recods, whose Catalog_ID fields equals the value in the variable "old_catalog_id" and insert identical recods with the "new_catalog_id" value.

The result of that operation on my sample records is:

Catalog_ID, Product_ID, IsBlocked
56789, 1, 0
56789, 3, 1
23567, 1, 0
23567, 2, 1
11111, 1, 0
11111, 3, 1

blue: selected fields
green: inserted fields


My Solution:
In order to realize this solution, I have created the following tasks on the Control Flow.

1. Create an Execute SQL Task for the selection. (Name: Selection Task)
2. Create a For-Each-Loop for iterating on the result set. (Name: Loop on results Container)
3. Create an Execute SQL Task inside the For-Each-Loop container for inserting the new records. (Name: Insertion Task)


Configurations and Problems:
1. Selection Task:
General Tab:
Result Set: Full Result Set
SQL Statement:
select Product_ID, IsBlocked
from MyTable
where Catalog_ID = ?


Parameter Mapping Tab:
Variable Name -- Direction -- Data Type -- Parameter Name
User:: old_catalog_version -- Input -- Large_Integer -- 0


Result Set Tab:
Result Name -- Varibale Name
0 -- User::FullResultSet (which has the Data Type: Object)


When I execute this task, I get no records.
Thus, I have hard-coded the value of Catalog_ID in the Sql Statement parameter. Now, I get the correct 2 records in the result set.
Question 1: What am I doing wrong in the Parameter Mapping?


2. Loop on results Container:
Collection Tab:
Enumerator: Foreach ADO Enumerator
ADO object source variable: User::FullResultSet
Enumeration mode: Rows in the first table


Variable Mappings Tab:
Variable -- Index
User:: old_prod_id -- 0 (Data Type of "old_prod_id" is Int64)
User:: old_isBlocked -- 1 (Data Type of "old_isBlocked" is Boolean)


When I execute the package, it fails with the following error message:
Error: 0xC001F009 at SQL Tasks: The type of the value being assigned to variable "User:: prod_id" differs from the current variable type. Variables may not change type during execution. Variable types are strict, except for variables of type Object.

Thus, I have changed the data type of the variable "old_prod_id" to Object. Now, the package runs successfully.


Question 2: Why isn't the package accepting "Int64" as the data type of my variable, although the corresponding DB field has the type "bigint"?


3. Insertion Task:
General Tab:
Result Set: None
SQL Statement:
insert into MyTable
(Catalog_ID, Product_ID, IsBlocked)
values (?, ?, ?)


Parameter Mapping Tab:
Variable Name -- Direction -- Data Type -- Parameter Name
User::new_catalog_version -- Input -- Large_Integer -- 0
User:: old_prod_id -- Input -- Large_Integer -- 1
User:: old_isBlocked -- Input -- Variant_Bool -- 2


When I execute this task, it fails with the following error message:
Error: 0x0 at Insertion Task: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Catalog2Context_CATALOGS". The conflict occurred in database "XS_EC_CCH_PEGXSAP2", table "eSearch4.CATALOGS", column 'ID'.


Well, the message implicitly states that the value of the variable "new_catalog_version" has violated the mentioned FOREIGN KEY constraint. But I have set a breakpoint and I saw that the value was set correctly. So, it seems that the Execute SQL Task is not able to read the value of the variable correctly.


Question 3: What am I doing wrong in the Parameter Mapping, which causes the task not being able to read the value of the variables correctly?


Thanks in advance for your help.


Regards,
Samar

View 3 Replies View Related

Parameters In Data Flow Task With Oracle Database Source

Jul 9, 2006

In many DTS packages I have used parameterised queries for incremental loads from Oracle database sources using the Microsoft ODBC Driver for Oracle.

Now I want to migrate these packages to SSIS, but the OLE DB connection for Oracle does not support parameters.

I cannot use the "SQL command from variable" data access mode because of the 4000 character limitation on the length of string variables and expressions.

Am I missing an obvious workaround?

View 7 Replies View Related

Integration Services :: Pass Parameters To SSIS Execute Process Task?

Nov 3, 2015

Got a powershell script to split a large XML file to split in smaller chunks. I have Execute ProcessTask in SSIS with: 

Executable: %windir%system32WindowsPowerShellv1.0powershell.exe

argument: -ExecutionPolicy ByPass -command ". 'C:WorkspacesSplitToytPMFile.ps1'"

I need to pass File Name as parameter to the PS script. I tried using the StandardInputVariable but it doesn't work. 

View 11 Replies View Related

Execute SQL Task : Input And Output Parameters In Tsql Stataments With ADO.NET Connection Type

Jan 2, 2007

Hi Everyone,

I haven't been able to successfully use the ADO.NET connection type to use both input and output parameters in an execute sql task containing just tsql statements (no stored procedure calls). I have successfully used input parameters on their own but when i combine it with output parameters it fails on the simplest of tasks.

I would really find it beneficial if you could use the flexibility of an ADO.NET connection type as the parameter marker and parameter name can be referenced anywhere throughout the sql statement in no particular order. The addition of an output parameter would really make it great!!

Thanks



 

 

View 11 Replies View Related

Integration Services :: SP Runs Fine In SSMS But Failed In Execute Task / All Parameters Checked Ok

Jul 30, 2015

There is one SP with parameters varchar, int, varchar and int. It runs perfect in SSMS. Now, I've moved into a Execute SQL task with four IN parameters. In parameter mapping, data type is varchar, long, varchar, long and parameter name is 0,1,2,3. It worked before which is great. Today, I opened this pkg for another testing but failed with the following error:failed with the following error: "Incorrect syntax near ';'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly,parameters not set correctly, or connection not established correctly.

I know SP is fine as tested in SSMS.  I could not understand where it could go wrong in the ssis package. Currently using Reporting Service 2000; Visual Studio .NET 2003; Visual Source Safe SSIS 2008 SSAS 2008, SVN --

View 12 Replies View Related

Integration Services :: Calling Oracle Stored Procedure With Output Parameters In OleDB Command Task?

Nov 7, 2015

I want to call "oracle" stored procedure with output parameter from SSIS ole db command task.

Actually I am able to successfully call the procedure but my Output value is not updating in the mapped column.

I used below PL/SQL query.

DECLARE
IS_VALID VARCHAR2(200);
BEGIN
IS_VALID(
PARAM1 => ?,
PARAM2 => ?,
IS_VALID => IS_VALID
);
? := IS_VALID;
END;

If I try to supply "OUTPUT" word I get error:

"ORA-06550: line 1, column 45:

PLS-00103: Encountered the symbol "OUTPUT" when expecting one of the following:   . ( ) , * @ % & = - + < / >"
BEGIN
IS_VALID(
?,
?,
? OUTPUT
);
END;

how to receive output parameter value of oledb command while calling oracle stored procedures.

View 4 Replies View Related

How To Pass Parameters To A Package Using A Execute Package Task

Jan 19, 2008

Hi,

I am calling one SSIS package from another using the Execute Package Task.
I also need to pass a parameter to the called SSIS package.
Can I do this? If yes, how? If no, then what will be the work-around for this?

Thanks in advance.

View 16 Replies View Related

SQL Query Parameters

Dec 19, 2006

I am trying to search a SQL database using a TextBox  and a DropDownList. The textbox being where the user enters there search query and the dropdownlist allowing them witch column to search.  If I hardcode in the table column to search everything works fine but as soon as I parameterize the column to search I no longer get any results.   While stepping through the code both parameters do get assigned the correct values to make the sql statement valid.  Any advice would be appreciated.
.... code that does not work .....
            string connection = ConfigurationManager.ConnectionStrings["serverlist"].ConnectionString;            string sqlquery = "SELECT server_id, hostname, os, description, owner FROM server_info WHERE @SearchItem=@SearchQuery";
            conn = new SqlConnection(connection);            comm = new SqlCommand(sqlquery, conn);
            String searchQuery = searchBox.Text;            String searchItem = DropDownList1.SelectedValue;
            comm.Parameters.Add("@SearchQuery", System.Data.SqlDbType.VarChar);            comm.Parameters["@SearchQuery"].Value = searchQuery;            comm.Parameters.Add("@SearchItem", System.Data.SqlDbType.VarChar);            comm.Parameters["@SearchItem"].Value = searchItem;
......

View 1 Replies View Related

Using Parameters In SQL Query

Jul 11, 2007

Hi all,
I am trying to write an sql query in my web application to select some records from the database using parameters. I use SqlClient for that. The query has a WHERE clause where its supposed to values from the various dropdownlists that I have in my application. I bind the SelectedValue from the dropdownlists to the appropriate parameters and the SQL query does not work if all the conditions are satified in the WHERE clause.
Can I have an SQL query where I can provide all the parameters in the WHERE clause (with AND conditions) and it takes only those values where there is some value from the dropdownlist and ignore the rest of the parameters.
This is what I am trying to do:  private DataSet GetSalesDataBas()
{
DataSet ds = new DataSet();
SqlConnection connection = new SqlConnection("...");
SqlCommand command = connection.CreateCommand();

SqlParameter prm_1 = new SqlParameter();
SqlParameter prm_2 = new SqlParameter();
SqlParameter prm_3 = new SqlParameter();
SqlParameter prm_4 = new SqlParameter();
SqlParameter prm_5 = new SqlParameter();
SqlParameter prm_6 = new SqlParameter();
SqlParameter prm_7 = new SqlParameter();

prm_1.ParameterName = "@pNum";
prm_2.ParameterName = "@sNum";
prm_3.ParameterName = "@paramLoc";
prm_4.ParameterName = "@paramDist";
prm_5.ParameterName = "@paramPNum";
prm_6.ParameterName = "@paramDesc";
prm_7.ParameterName = "@paramBuild";

prm_1.Value = TextBox2.Text.Trim();
prm_2.Value = TextBox3.Text.Trim();
prm_3.Value = DropDownList15.SelectedValue;
prm_4.Value = DropDownList12.SelectedValue;
prm_5.Value = DropDownList21.SelectedValue;
prm_6.Value = DropDownList13.SelectedValue;
prm_7.Value = DropDownList18.SelectedValue;

command.Parameters.Add(prm_1);
command.Parameters.Add(prm_2);
command.Parameters.Add(prm_3);
command.Parameters.Add(prm_4);
command.Parameters.Add(prm_5);
command.Parameters.Add(prm_6);
command.Parameters.Add(prm_7);

string strWhere = "";

if (DropDownList23.SelectedIndex == 0)//if no sort field selected
{
strWhere = @" WHERE ""UserName""='" + userName + "' AND ([Status] LIKE 'REF%A' OR [Status] LIKE 'A%')" +
" AND m.[Part Number] LIKE '%' + @pNum + '%'" +
" AND m.[Serial Number] LIKE '%' + @sNum + '%'" +
" AND (Location = @paramLoc" +
" AND m.[District] = @paramDist" +
" AND m.[Part Number]= @paramPNum" +
" AND m.[Description]= @paramDesc" +
" AND m.[Building]= @paramBuild" +
")";
}
else
{
strWhere = @" WHERE ""UserName""='" + userName + "' AND ([Status] LIKE 'REF%A' OR [Status] LIKE 'A%')" +
" AND m.[Part Number] LIKE '%' + @pNum + '%'" +
" AND m.[Serial Number] LIKE '%' + @sNum + '%'" +
" AND (Location= @paramLoc" +
" AND m.[District]= @paramDist" +
" AND m.[Part Number]= @paramPNum" +
" AND m.[Description]= @paramDesc" +
" AND m.[Building]= @paramBuild" +
")" +
" ORDER BY " + DropDownList23.SelectedValue + " " + DropDownList24.SelectedValue;
}

string sqlSalesData = @"SELECT * FROM Main m" + strWhere;
command.CommandText = sqlSalesData;
SqlDataAdapter salesOrderAdapter = new SqlDataAdapter(command);
salesOrderAdapter.Fill(ds, "Main");
salesOrderAdapter.Dispose();
command.Dispose();
return ds;
}    

View 7 Replies View Related

DTS Query Parameters

Mar 14, 2002

I am creating a package within which I have a query step that needs to accept
a value from a variable step that has already been run, but I cant get it to work and the books online dont help!

The query is simple

insert into table1
select col1 = cola,
col2 = colb,
col3 = ?
from tableA

Even though the variable that I want use has been set, I cant get the query to recognise there are any parameters. If I click the parameter button in the query set-up, I get a message saying that col3 is an invalid column name and then a box saying that an error occured when parsing the statement fro parameters !

Can anybody help ?
Thanks
Tom

View 1 Replies View Related

Parameters For Query

Oct 19, 2006

I'm not sure if any1 can answer is on this forum, but any help would be VERY appriceted....

I am creating a report using Visual Studio.Net..I want to write a query using parameters BUT in this case I dont no what the parameter will be...

ie the user can enter a customer account OR a customer group
and sort can be on product OR total sales...

Any ideas?!

Thanks!!! :)

View 9 Replies View Related

MDX Query With Parameters

Jul 25, 2007

Hi there,

I'm developing one MDX query to place in my report, but I'm having a lot of troubles when using one of my report parameters.

I hope I can explain me good enough.

I have a report parameter that's used in the WHERE clause to choose the value of one of my dimensions, the problem is that I'm also trying to compare the value of this parameter to decide the value of another dimension, but the comparison isn't working at all.

Let me show one example:

The parameter name in question is: DimFolderWalletDesciption.




Code Snippet


IIF(
@DimFolderWalletDesciption = [Dim Folder].[Wallet Desciption].&[Investimento],
[Dim Indexation].[Indexation Group].[Rendimento Variável],
[Dim Indexation].[Indexation Group].[Indexation Group].ALLMEMBERS
)


This is suppost to do the following: If my parameter as the selected value "Investimento", then the "Indexation Group" selected should be "Rendimento Fixo" if not, there shouldn't be any "filter" in the Dimension "Indexation Group".

I've tryed a lot of combinations, but none works, what am I doing wrong?

Thanks in advance.
Regards.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved