Showing posts with label connection. Show all posts
Showing posts with label connection. Show all posts

Thursday, March 22, 2012

Build a Connection String Programmatically

I'm getting really frustrated with using the web.config to store all database information. It seems like you really don't have any real flexibilty when moving an application from server to server (between dev, test and prod). Seems like you have to create separate config files when you move it every time. Seems like you always run into a risk of over writing one of them if you are not careful.

Is there a good way to design the connection object to be able to tell which server it is on and determine if it's a test, dev or prod type of connection. I have used a basic three connection strings that it will compare the computer name with the key. But again, the connection string is hard coded in the web config. At least this way I am able to move all code together without the worry of overwritting the config file. I just have to beleive there is a better way to build something like this. I've heard of setting up enviroment variables on the server, but not sure how safe that is.

I'm looking everywhere on the web, but get really lame examples. If anyone knows a good method or a sample I can check out, that would be great.

Thanks!

Im not sure about building a connectionstring dynamically, but the generally accepted way to solve this is with a User.config file for you and the host. You keep all the normal crap in the webconfig, and then your connection string and any other variables in the userconfig. Here is a good example.

http://blogs.msdn.com/rprabhu/articles/433979.aspx

Tuesday, March 20, 2012

Bug?

When I have two connection managers in the DFT and OLEDB source and destination component.

Associating the different conneciton managers to source and destination seem to go through fine with the code below, but the package generated does not have the connection manager associated with the destination.

I get this error on the destionation on opening up the package in the designer.

<Error> A connection Manager has not been assigned to the runtime connection (24) </Error>

SourceOrDestinationComponent.RuntimeConnectionCollection[0].ConnectionManager = DtsConvert.ToConnectionManager90(pkg.Connections[ConnMgrName]);

However when I assign the ID using the code below it seem to work fine. The documentation doesn't mention needing this step, so is this a bug or a documentation issue?

SourceOrDestinationComponent.RuntimeConnectionCollection[0].ConnectionManagerID = pkg.Connections[ConnMgrName].ID;

Also is the BOL documentation being updated for how to program/configure various tasks in SSIS? Without which it is extremely time consuming with a trial and error method if at all impossible to use them (programmatically)

-tim

Tim,

That step is definately needed and the documentation should say so. If it doesn't say it then use the Send feedback link to tell them. You may be surprised at how effective this is.

If you need anything extra in BOL then ask them for it. It is constantly being updated.

-Jamie

|||

Thanks Jamie, I know the folks working on BOL content appreciate the comments.

This seems like a great opportunity to point out the recent/July refresh of BOL

>>>>>>>>>>>>>>>>>>>>>>>>>>>

Download an updated version of the documentation and tutorials for Microsoft SQL Server 2005. See the "Additional Information" section for an update on SQL Server Express Books Online.

http://www.microsoft.com/downloads/details.aspx?FamilyId=BE6A2C5D-00DF-4220-B133-29C1E0B6585F&displaylang=en

There is a separate download for the sample packages, programs, and databases, at http://www.microsoft.com/downloads/details.aspx?familyid=E719ECF7-9F46-4312-AF89-6AD8702E4E6E&displaylang=en.

|||

Thank you both. The new documentation still does not include the required step.

Craig, BOL seem to have provided clearified some of the existing samples , but it still does not contain samples to how to programmatically most components eg: SCD. Can we expect more samples to be updated to BOL going forward?

Till that time what is the recommended way for people to figure out how to use these apart from trial and error

|||

We are continually updating BOL and I will pass along a note on this one and as Jamie noted, using the feedback mechanism for BOL is really the best way. I can certainly suggest/ask for doc changes but requests from customers always carry more weight. One complication is that every connection mgr may behave differently. Connections and data providers are tricky as each has its own behavior.

sql

bug: name change of connection manager is not propogated through package

create a package with a connection manager

reference the manager with a bunch of tasks

change the name of the manager

stand back in disbelief as you receive the following message

Error: 0xC004800B at Data Flow Task, DTS.Pipeline: Cannot find the connection manager with ID "SourceConnectionExcel" in the connection manager collection due to error code 0xC0010009. That connection manager is needed by "runtime connection "OleDbConnection" (8)" in the connection manager collection of "component "Source - 'DCD MANUAL$'" (1)". Verify that a connection manager in the connection manager collection, Connections, has been created with that ID.

SSIS? SSUX

What version of SSIS are you using? RTM? SP1? SP2?

I rename connection managers all of the time and never have a problem. SP1 and SP2 depending on which machine I'm on.

|||

Microsoft SQL Server Management Studio 9.00.3042.00
Microsoft Analysis Services Client Tools 2005.090.3042.00
Microsoft Data Access Components (MDAC) 2000.085.1117.00 (xpsp_sp2_rtm.040803-2158)
Microsoft MSXML 2.6 3.0 4.0 5.0 6.0
Microsoft Internet Explorer 6.0.2900.2180
Microsoft .NET Framework 2.0.50727.42
Operating System 5.1.2600

Microsoft SQL Server Integration Services Designer
Version 9.00.3042.00

|||

You probably generated your package using the Import/Export wizard. The wizard use to reference connection managers in sources and destinations using the names instead of IDs. That would work better if you copy both componets and connections to another package but breaks when you try to rename connection managers.

The problem should be easy to correct: just open the component UI and select the connection again. Feel free to open a bug on the connect site as well.

Thanks,

Bob

Monday, March 19, 2012

Bug with Renaming Connection

I used the wizard to create a package that loads data from Access into SQL Server 2005. I then saved the package to the File System and added to my project.

I had two connections, one for SQL and one for Access. When I rename either one, the source or destination tasks in the Data Flow task reset to the other connection and/or I get an error that the old connection ID cannot be found.

I solved by opening the dtsx in Notepad and doing a global find/replace for the connection ID's. This is a real hassle.

Are you right-clicking on the connection manager and selecting rename? Or how are you renaming them?|||

That was how I tried to rename, by right-clicking. Also tried within the Properties and in the Package Explorer. Same thing.

|||

Do you want to know another bug. In the Import Data wizard that creates the package, I checked the Source box in the upper left which selected all the tables. I then went into Edit Mappings and checked to Delete Rows in Destination Tables.

However, when I execute the package, it doesn't delete the rows and instead appends the data. It might be because I am importing a lot of tables, because when I tried one table only, it worked. I believe it calls sp_executesql to execute the SQL statement and maybe the sql statement string is too long. Unfortunately, it doesn't warn that anything is incorrect, so one doesn't discover this until after testing. Don't mind bugs, but a bug like this without any kind of warning message is kind of dangerous.

|||

When building a package from the designer, renaming connections is fine, because actually the task stores the connection ID not the name.

I did a quick test with a Wizard built package and it varies, for example a snippet of the Exec SQL Task <SQLTask:SqlTaskData SQLTask:Connection="{5545ACCD-6E14-45EF-9112-2AC292C30609}" shows the use of the ID, so renames should keep working just fine, except that other stuff is doing it wrong.

For example an OLE-DB destination shows <connection id="48" name="OleDbConnection" description="The OLE DB runtime connection used to access the database." connectionManagerID="DestinationConnectionOLEDB"/></connections> which uses the name.

If I then open the package, and open the UI and close it again for the OLE-DB component, the XMl is changed to this <connection id="48" name="OleDbConnection" description="The OLE DB runtime connection used to access the database." connectionManagerID="{5545ACCD-6E14-45EF-9112-2AC292C30609}"/></connections> which clearly will survive a rename.

So why not log it at http://connect.microsoft.com

By the way, stop using notepad if you have added the package to a project. Just right click the package in the Solution Explore and select View Code. You get a much nicer text editor with better find and replace, and it keeps it all nicely liked to the designer window for the package as well. Much easier for when you do want to hack package XML directly.

Thursday, March 8, 2012

BUG in Integration Services

Problem

When you have a SSIS package that contains a connection from a data source, this connection is not updated when the data source changes based on a configuration change.

Situation :

A SSIS solution contains 3 configurations : Development, Test, Production. You can create those configurations in configuration manager of the solution.

The SSIS project contains one Data source. It doesn't really matter what type but I take SQL Server. The database server in development is SQL_DEV, in test is SQL_TEST and in production is SQL_PROD. Initially they are for all configurations the same. You can specify those values by changing the active configuration and then editing the Data source.

In the SSIS package (DTSX), you can create a connection manager based on a Data source.

If you change the Data source, the connection manager is also changed. If you change the Data source by changing the active configuration, the connection manager is not being updated.

If you think this isn't a big issue think big. We have 4 configuration, 10 shared Data sources and 25 DTSX packages. That would give a maximum of 1000 settings (4 x 10 x 25). Using this method it can be reduced to 40 (4 x 10). Of course this is a theoretical but it is very common to have the destination data source re-used on all packages, which still would be 100 settings (4 x 25)

Steps to reproduce

- create a new SSIS project

- In the solution explorer, create a new Data source named TestSource.

- In the connection managers window of Package.dtsx, create a new connection from a Data source.

- Make some changes in to TestSource.ds under the Data Sources. For example change the server or the database.

- Verify that those changes are also in the package.

- in the solution explorer, right click the solution and select configuration manager

- under active solution configuration, create a new configuration named test.

- Set the copy settings from : development

- Verify that Create new project configuration is checked.

- click OK and close.

- Notice that the active configuration is now Test

- Make some changes the Testsource.ds like a different server.

- Verify that those changes are also in the package.

- Make the development configuration as active.

- Notice that the Testsource.ds contains now the original settings.

- You will notice that the connection manager still contains the "test" settings and not the development settings.

- If you create a deployment utility it will still contains the wrong values.

with regards,

Constantijn Enders

Don't use Data Sources. Just use the connection managers and use package configurations to configure them.

Bug in Flat File Connection Object: Risky!!!!

I was wondering if any others on this list are getting a bug with the Flat File connection object --where in both csv (coma delimited) or flat files (tab delimited) where strange characters(like two bold vertical lines) are appearing in the file viewer while setting up a connection forcing the CRLF to end in the wrong place. They look like two bold vertical lines

Im testing the same files with both the old DTS from SQL Server 2000 and getting no issues which tells me there is a bug in SSIS. Strange thing the bug does not happen with every file I receive, only a few. I’m wondering if SSIS Flat File Connection object could be a little flaky with respect to how it reads files compared to DTS text connection object.

email me d2ba@.xtra.co.nz for a screen shot of tests

Thanks in advance

Dave

This is due to the way the SSIS flat file parser is designed. Missing delimiters break the parsing. See the following post fo more details:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=67416&SiteID=1

Thanks.

|||

Bob,

I had a read --all I can say is Risky to implement the flat file connection object this way in an ETL tool. Risky Risky Risky

The best workaround is to use DTS 2000 to import the flat files.Simply run the DTS 2000 package via SQL Server 2005 Agent using the backwards compatibily.

Once the data is in the SQL Server 2005 staging tables use SSIS for the rest of the package.

Cheers Dave

|||

I have to say I am puzzled by the term "risky" - the behaviour of the current flat file parser is entirely predictable and was introduced in part because the old DTS behaviour could introduce unexpected results - it was also much slower.

The two black characters you are seeing are probably undisplayable characters such as <CR> or <LF>. I expect they are in some lines in some files and not in others - but you might not be able to tell that in other editors as they are undisplayable. I would think it much more risky to behave as if they were not there or to make assumptions as to what was intended when a certain parsing was selected. And indeed, we have plenty of issues in our bug database and customer feedback concerned about the DTS parsing for these reasons.

That's not to say that we could not introduce more flexibility into the current design - although all the flexibility one could want is available through the script source component in 2005.

Perhaps there are some specific aspects of the older DTS parsing you would like to retain, and I would be glad to hear of those. We're always open to suggestions.

Donald

|||I also saw this. Nothing is perfect. I will prefer SSIS to DTS within six months no right now, when I've got as a dutie move hundreds of packages to SSIS, you know. Old habits...|||

Here is what I would like to see in the next release:Until then Im stuck with using DTS imported into SSIS for the dataflow task on certain file types we recieve--unless somebody can show me a script component that can to this. Sometimes I have first row as column names in file and other times I dont have column names in file.

the row delimiter used to be read before the column delimiter in the DTS world... it would be great to be able to set this as an explicitly selected option

Problem Statement:

I have a tab delimited flat file with say 60 columns. All columns can have null values. The file contains a blank tab for nulls.

Now, if a row has null value for last 10 columns, ideally, there should be 10 blank tabs padded to the end of that row. But, this is not the case with this file. There is line break after 50 columns of that row, in the above example.

Extrapolating this behavior, most of the rows have null values for last 'x' columns where 'x' is variable for each row.

When I try to customize a flat file connection for this file, SSIS is not padding up the missing tabs. In the example above, it should insert null in the last 10 columns for that row. Instead, and weirdly, it is continuing to read next row. So, column 1 of next row is inserted into 51 st columns of the above row.

Even Excel 2000 can handle this same file easily with the same delimiters (row - LF and column - tab).

Reason Why SSIS behaves this way:

The flat file parser parses data per-column using current column delimiters, and then advancing to the next one. The row delimiter is considered as nothing more then a column delimiter of the last column.

We considered adding what you are asking for; always check if we get the row delimiter in addition to checking for the current column delimiter, and if the row delimiter comes before expected column delimiter pad the remaining columns of that row.

We decided not to implement this by default for performance reasons. It is likely we will have it in the next version of the product, but only as an option that will need to be explicitly selected.

|||

I'm sorry I don't have time to craft a full script sample for you - perhaps someone out there in the community may be able to.

Is there a specific issue with writing the script that is causing problems? I may be able to advise.

Meanwhile - we'll continue to consider alternative parsing methods for future releases.

Donald

|||

Dave,

I am not an advanced user of SSIS at all BUT things that used to be simple in DTS are often more convoluted than I'd expect in SSIS. Indeed, I ran into various problems with their Flat File Connection object but I presumed that it was my lack of understanding of how to use it. They just seem to have re-architected the way some familiar things worked and have not done a very good job of telling people how they have changed.

Barkingdog.

Wednesday, March 7, 2012

Bug ?->Can not make a new connection to SQL Server 2005 X64

Can not make a new connection to SQL Server 2005 X64 until the SQL Server
service is restarted.
OS is Windows 2003 X64 Enterprise Edition all updates are applied.
This repeats every few hours. Server protocols enabled are TCP IP and Named
Pipes
Client protocols are Named Piped only.
The following error is thrown MSg 17
"SQL Server does not exist or access is denied"
Since I am not finding solution this problem on many forums I assume this is
a bug.
Thanks
Kiran"SQL Server does not exist or access is denied" could indicate a problem
resolving the name of the instance. Is this a default instance listening on
the default named pipe, or a named instance? The second would require the
SQL Server Browser Service or require connecting to a specific pipe name. So
is the SQL Server Browser Service running?
--
Rick Byham
MCDBA, MCSE, MCSA
Documentation Manager,
Microsoft, SQL Server Books Online
This posting is provided "as is" with
no warranties, and confers no rights.
"Kiran" <Kiran@.discussions.microsoft.com> wrote in message
news:9CED6B9C-9643-43C5-9961-8BD1E00BFA8A@.microsoft.com...
> Can not make a new connection to SQL Server 2005 X64 until the SQL Server
> service is restarted.
> OS is Windows 2003 X64 Enterprise Edition all updates are applied.
> This repeats every few hours. Server protocols enabled are TCP IP and
> Named
> Pipes
> Client protocols are Named Piped only.
> The following error is thrown MSg 17
> "SQL Server does not exist or access is denied"
> Since I am not finding solution this problem on many forums I assume this
> is
> a bug.
> Thanks
> Kiran
>

Bug ?->Can not make a new connection to SQL Server 2005 X64

Can not make a new connection to SQL Server 2005 X64 until the SQL Server
service is restarted.
OS is Windows 2003 X64 Enterprise Edition all updates are applied.
This repeats every few hours. Server protocols enabled are TCP IP and Named
Pipes
Client protocols are Named Piped only.
The following error is thrown MSg 17
"SQL Server does not exist or access is denied"
Since I am not finding solution this problem on many forums I assume this is
a bug.
Thanks
Kiran
"SQL Server does not exist or access is denied" could indicate a problem
resolving the name of the instance. Is this a default instance listening on
the default named pipe, or a named instance? The second would require the
SQL Server Browser Service or require connecting to a specific pipe name. So
is the SQL Server Browser Service running?
Rick Byham
MCDBA, MCSE, MCSA
Documentation Manager,
Microsoft, SQL Server Books Online
This posting is provided "as is" with
no warranties, and confers no rights.
"Kiran" <Kiran@.discussions.microsoft.com> wrote in message
news:9CED6B9C-9643-43C5-9961-8BD1E00BFA8A@.microsoft.com...
> Can not make a new connection to SQL Server 2005 X64 until the SQL Server
> service is restarted.
> OS is Windows 2003 X64 Enterprise Edition all updates are applied.
> This repeats every few hours. Server protocols enabled are TCP IP and
> Named
> Pipes
> Client protocols are Named Piped only.
> The following error is thrown MSg 17
> "SQL Server does not exist or access is denied"
> Since I am not finding solution this problem on many forums I assume this
> is
> a bug.
> Thanks
> Kiran
>

buffered trigger

Hallo i need to read/write data using triggers between two remote MSSQL2K servers, over an unstable connection.
Can trigger operations be buffered, so they are completed when connection is on?
Or should i make the triggers to write into local tables, then replicated in merge? (i would like to avoid this)

No. Trigger is part of the active transaction so if you have an unstable remote connection, I would suggest you queue your data into a worker queue table and process it later. I suggest you take a look at Service Broker in book online. It's designed for message queue/processing.

|||

This asyncronous read/write data can be resolved using SQL Service Broker a feature of SQL Server Express 2005 (that is free).

My ideea is :

1.The trigger of SQL2K1 server write the data in a Table1 of SQL2K1

2.SSSBroker get the data of Table1 in a Table2 from SSEXPRESServer in a Database1

3.From Table2 SSExpress copy data to SQL2K2

HTH