December 1, 2011 at 1:45 pm
Hi, I am using ADODB to get data from SQL server in a script task using code below
Dim Server, Database, Username, Password
Dim ADOCN As New ADODB.Connection
Dim ADORS As New ADODB.Recordset
Dim Catno, X, Y, Z, StrSQL, StrCON, Main_No
Server = "xxx"
Database = "yyy"
Username = "zzz
Password = "aaa"
StrCON = "DRIVER={SQL Server};SERVER=" & Server & ";" & _
"DATABASE=" & Database & ";UID=" & Username & ";PWD=" & Password
ADOCN.Open StrCON
StrSQL = "select * from iv00102 where itemnmbr = '00016'"
ADORS.Open StrSQL, ADOCN
How can i use connection manager and use the same code to connect to data source defined in the package for using the same code.
What do i replace these lines with to use a predefined connection called "SQLConnection"
StrCON = "DRIVER={SQL Server};SERVER=" & Server & ";" & _
"DATABASE=" & Database & ";UID=" & Username & ";PWD=" & Password
ADOCN.Open StrCON
Please advise. Thanks in advance.
December 1, 2011 at 2:07 pm
You're connecting to a SQL Server database? Just use the OLE DB Source as your component and follow the on-screen steps to connect, then use the SQL Command option as your source and put your query in.
You shouldn't use SELECT * btw, change it to get only the fields you need.
December 1, 2011 at 2:18 pm
I need to connect to it in a script task. I need to do some processing on the data and save it to other tables. I do need to do it in script task FYI.
Got the point about not using select *. thanks for that.
December 1, 2011 at 2:29 pm
I'd really strongly recommend that you instead do the processing using SSIS components. That's the whole point of using SSIS Pretty much everything you could do with the script component, you can do with the other built-in components.
Why don't you post what you're trying to accomplish and we can try and find a way to help you to do it with the other components?
December 2, 2011 at 8:36 am
I have on very rare occasion used a script task to read SQL data in SSIS, and in those cases only when I had to do something that was very difficult in SQL. Unfortunately I can't name the cases right now but they were kind of last resorts. I would strongly recommend not doing this. You might add a script transform in the pipeline to to the manipulations but I would try VERY hard to NOT use it as a source in this case.
CEWII
December 2, 2011 at 8:39 am
Check this link.
Hope that it helps.
Thanks...Chris
December 2, 2011 at 9:22 am
It's too late for that. I have coded many packages using these techniques. Just need to change the way the connection to server is done. It would help me a lot if someone could tell me how to replace the code to use connection manager.
December 2, 2011 at 9:28 am
Did you see my post?
- Chris
December 2, 2011 at 9:30 am
Chris, sorry, yes I just saw it. i had the browser open and didn't refresh before posting the reply. I think that would work. I am trying it now to see. thanks
Viewing 9 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy