Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Using Parameters with the DataReader odbc SqlCommand

Posted on 2009-07-09
10
Medium Priority
?
1,478 Views
Last Modified: 2013-11-10
In my DataReader object of my SSIS package, I need to be able to pass in a date and time to the query. The correct date and time values are stored in a variable that I populate in a prior "Execute SQL Task" component in my Control Flow. I need to access the value in those variables to execute my dataReader.

How do you do this?
0
Comment
Question by:_Wade_
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 5

Expert Comment

by:jbyers79
ID: 24817979
if you want to use parameters, don't use the DataReader component.  Can you use the OLEDB data source component?
0
 
LVL 15

Expert Comment

by:rob_farley
ID: 24820082
It's definitely easier to do this using an OLEDB Source, and I find that I only ever use DataReader if I have a client who insists on using ADO.Net in between. The DataReader component is just far too restricted in its use.

Rob
0
 
LVL 22

Expert Comment

by:PedroCGD
ID: 24823523
You can use parameters using OLEDB Source or Data Reader Source.
OLEDB Source is more easy... with Data Reader you need to use expression are is not soo complicated.
Do you want more details?

Helped?
Regards,
Pedro
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:_Wade_
ID: 24825785
Hi everyone. thanks for your responses. the reason why I'm using a DataReader is because I'm having to use ODBC. I'm accessing an AS400 datasource.

I'm assuming there's no other component besides DataReader for this.

I figured out how to use expressions yesterday for the datareader. SSIS is just so wonderful! I discovered that in order to do this "workaround" I needed to "fake" the Visual Studio designer out by giving the data reader a bogus sql command for it to populate it's metadata with column information. I post I found assured me that it it would work at runtime....

But, when i run my SSIS package it won't begin. It tells me there's a problem with the Datareader SQL command before it even gets to that point in the execution (it won't even execute the first step in the control flow).  It's pretty nonspecific. If it wouldn't let me cut and past the error (which was displayed in a dialog box instead of somewhere that I could access the actual text) I would show everyone the exact message. It had a few lines which made no sense, or at least told me nothing meaningful about what was wrong with my sql statement. It can't be a problem with parsing, since it didn't get far enough to parse against the actual datasource.

SSIS is giving me such a headache my boss told me to redesign my process with a VB.net console job. I'm doing that right now. It might prove easier. I've got less than a year in development experience so it's hard for me to tell these things in advance. :)

0
 
LVL 22

Expert Comment

by:PedroCGD
ID: 24825808
do you want an example?
0
 

Author Comment

by:_Wade_
ID: 24825857
Sure!
0
 
LVL 15

Expert Comment

by:rob_farley
ID: 24828336
You should be able to use an OLEDB source, using an OLEDB for ODBC provider.

... and it's a lot more forgiving.

Rob
0
 
LVL 22

Accepted Solution

by:
PedroCGD earned 1000 total points
ID: 24850140
0
 

Author Comment

by:_Wade_
ID: 24850250
That was a great example. Thanks Pedro!
0
 
LVL 22

Expert Comment

by:PedroCGD
ID: 24850270
It's a pleasure!!
Regards,
Pedro
www.pedrocgd.blogspot.com
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question