How To Change Dynamically The Connection String.
Nov 15, 2007
Hi,
I am looking to dynamically change the connection string in my SSIS package, to avoid changing the connection string each time I want to run in different environments.
Thanks in advance
View 3 Replies
ADVERTISEMENT
Oct 31, 2006
Hi Folks ...Question for everyone that I have not been able to figure out. I have an application that is spread across tiers:SQL Connection defined in Web.Config file that connects to SQLServer database.DAL layer created references SQL Connection in Web.Config file - have noticed this copies the connection string information to the local properties for each TableAdapter that is defined in the DAL layer.BLL Layer that references Table Adapters declared in the DAL layer.When the web site is called, the link will provide an encoded id.Sample call to website: http://www.mysamplesite.com/default.aspx?company=AE2837FG28F7B327Based on the encoded id that is passed to the site, I need to switch the connection string to use different databases on the backend.Sample connection string: Data Source=localhost;Initial Catalog=dbSystem_LiveCorp1;User ID=client;Password=live2006 I would need to change Initial Catablog to the following:Data Source=localhost;Initial Catalog=dbSystem_LiveCorp196;User ID=client;Password=live2006How do I do this and have the connection string reflected in all of the Table Adapters that I have created in the DAL layer - currently 100+ Table Adapters have been defined.As we gain new clients, I need to be able to have each clients information located in a different database within SQL Server. Mandated - I have no choice in this requirement. Being as I don't want to have to recreate the DAL for several dozen clients and maintain that whenever I make a change to the DAL to then replicate across multiple copies. There has to be a way to dynamically alter the SQLConnection and have it recognized across all DAL TableAdapters.I'm developing with MS-Visual Studio 2005 - VB. Any help would be greatly appreciated. Thanks ...David Any day above ground is a good day ...
View 1 Replies
View Related
Oct 26, 2007
Hi. I have this kind of problem since I am not very conversant with SSIS
and stripting in VB.NET.
The set-up is the following:
Flat File Source -> Script Component -> Flat File Destination
The flat file source looks like this:
NameOfFile
Headers
Data
Data
Data and many more rows of Data
NameOfAnotherFile
Headers
Data
Data
Data and many more rows
NameOfAnotherFile
Headers
Data
Data and so on in the same manner...
My stript looks like that (not very complicated):
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
Dim strRow As String = Row.Column0.Trim()
Dim strFolder As String = "Data"
Dim strConn As String
Dim charSep() As Char = {CChar(" ")}
If Mid(strRow.ToLower(), 1, 2) = "d0" Then
' This is the file name, so start a new connection to a new file
' which definitely does not exist yet
strConn = strFolder + strRow + ".csv"
' DestinationFile is the name of the
' Flat File Connection Manager
With Me.Connections.DestinationFile
.ConnectionString = strConn
End With
Else
Row.Column0 = String.Join(",", strRow.Split(charSep, StringSplitOptions.RemoveEmptyEntries))
End If
End Sub
I have several questions regarding this one.
1. Is it ok to change the ConnectionString property of the manager
to redirect the row to a different file? If not, what more to do?
2. If the new destination file does not yet exist, will it be created for me or will
I get an error? If I do, what to do not to?
3. The most important: What steps to take so that a row is discarded
from the pipeline in the script? I want some rows not to be directed
to the file destination. These are the lines that contain the name
of the file into which the data below belongs.
If you can optimize some steps in the script, then please do so by all means.
Thank you for any comments and the knowledge you kindly agree to share with me.
Darek
View 1 Replies
View Related
Feb 28, 2008
I have 3 web identical web apps whose only diff is that they access different SQl Server DB's. I use the SQLDataSource in a number of pages to retrieve data from the db. The apps all use Forms Auth. I would like to be able to see who is the logged on user user and assign the approp connection string to all the SQLDataSources in the app. For example when user UserA logs in they are retrieving data from on db but when UserB logs in they are retrieving data from another db.
I am sure this can be done but could use a little guidance. Thanks in advance.
View 1 Replies
View Related
Apr 18, 2008
I need to make my site aware of which server_name it is loading from so it uses a different connection string. (have dev + prod servers for web/sql)Currently my connection string is in web.config as follows: <connectionStrings> <!-- Development and Staging connection string --> <add name="myconnection" connectionString="server=myserver; user id=mysuer; password=mypassword; database=mydatabase" /> </connectionStrings> I need to make sure the 'name' is the same for both connection strings since that is how the rest of my site looks for it. However, I'm not sure how to get both in here with some sort of 'if/then' statement to determine which one to use.I've heard it could be done in global.asax with something similar to the code below, but I dont know how to assign a 'name' to a connection string for that type of setup. Sub
Session_OnStart ServerName =
UCase(Request.ServerVariables("SERVER_NAME")) IF ServerName = "prod.server.com" THEN ...Set Prd string... ELSE ...Set Dev string... END IF End
Sub
View 8 Replies
View Related
Mar 12, 2008
Hi,
I tried to follow the widely talked about method to dynamically populate the connection string property of my flatfileconnection manager from a variable. I keep getting the following non-fatal error.
TITLE: Microsoft Visual Studio
------------------------------
Nonfatal errors occurred while saving the package:
Error at Package [Connection manager "FFCM"]: The file name ""C:ProjectsSSISHLoadTOutputOut.csv"" specified in the connection was not valid.
Error at Package: The result of the expression "@[User::CsvFullFileName]" on property "ConnectionString" cannot be written to the property. The expression was evaluated, but cannot be set on the property.
Here is what I am trying to do.
I have a foreach loop that iterates through a list of xml config files and reads the config information including the destination csv file name and does a data transformation.
So I created a flatfile connection to a csv file did my data mappings.
Created a package level variable to hold the destination file path
In the Flat file conn. manager's properties -> expression -> set the @[User::CsvFullFileName] (which even evaluates fine)
When I try to run the package I keep getting the above mentioned non-fatal error..I checked the path and it is valid. I even tried
the c:\projects\...notation and the UNC path notation...all seem to give the same error
Anyone experience this before ? any thoughts would be appreciated.
Thanks
View 5 Replies
View Related
Jul 12, 2012
I have create packages which loads the data from flat file to sql server table, now I want to make my destination table connection dynamic what is format of connection string. I also need to pass user name and password for sql server dynamically in this case, what is the format for the connection string.
Also in package i used ADO.net as source for *.mdb files how i can set the commection to .mdb files dynamically which is used as source in my package.
View 8 Replies
View Related
Dec 13, 2006
I have a SSIS Package which I developed on my own my database server.
But now the package is to deployed on 3-4 different computers pointing it to different databases.
I do not want to change the connection string for each and every instance because in future there may be more number of instances running.I tried using the Configuration file and add that file in to the configuration window but that also did not work.Please can anybody help me?
View 3 Replies
View Related
Mar 9, 2007
I've recently uploaded my website, http://www.bigredsongbus.com, to my host. Unfortunately, they don't support the use of SQL Server Express. So, I've purchased an addon through my host - discountasp.net. I've attached my database file to their server, now all that I need to do is to change the connection string in my .config file so that it points to the SQL Server. I don't know how to do this. Any help, please?Jeffrey Way
View 2 Replies
View Related
Dec 21, 2007
I know that connecttimeout and commandtimeout are separate entities. Is it possible to change the default command timeout value by changing the connection string?
I need to increase the command timeout and want to know if I can do it without changing my code and rebuilding my ASP.NET 1.1 web app.
Thanks in advance. -- ZLA
View 4 Replies
View Related
Jun 19, 2007
Hello,
I have searched every post and tried every connection string there but can't figure out how to connect to my database on my remote server. I am using Visual Developer 2005 Express Edition in C# and uploading it to a Windows server running asp.net 2.0. The domain has not resolved yet.
I am so new to this and have followed many tutorials step by step but none of them address this issue. They just show how to upload it to the server.
Do I need to use the SQL server provided by my host or can the database stay in the App_Data folder?
My local connection string works locally:
<add name="ConnectionString" connectionString="Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|add_newSQL.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
When I uploaded to my server I changed SQLEXPRESS to (local) as advised in the forum.
<add name="ConnectionString" connectionString="Data Source=(local);AttachDbFilename=|DataDirectory|add_newSQL.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
When I debug a page I get the <customErrors mode="Off"/>
error message even thought I have already set it in my remote web.config file which may be causing problems itself:
<configuration>
<appSettings/>
<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=(local);AttachDbFilename=|DataDirectory|add_newSQL.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<customErrors mode="Off" />
<compilation debug="false" />
<authentication mode="Windows" />
</system.web>
</configuration>
Thanks for any help you can offer. I wish I could find someone to hire to do this part for me or teach me how over the phone. Any suggestions?
View 6 Replies
View Related
Apr 5, 2006
Do I need to change connection string if I upgrage SQL server from 2000 to 2005 in ASP.NET 2.0?
View 1 Replies
View Related
May 28, 2014
One of my excel 2013 power pivot report was migrated from old server to new server after migration i changed the excel power pivot connection string to connect with new server but the workbook connections is still taking the old connection string of old server and there is no option of changing workbook connection string .
I am able to edit the powerpivot connection but workbook connections are not getting updated they are still taking old server connection string.
View 12 Replies
View Related
Oct 1, 2007
I am trying to filter some results using the FilterExpression Property of the SqlDataSource. I have multiple drop down lists with different filtering options. I am trying to change the filter that is applied to a gridview.
Something like this example... http://blogs.vbcity.com/mcintyre/archive/2006/08/17.aspx
Here is some of my code..Private Sub ApplyFilter()
Dim _filterExpression As String = ""
If (Not DropDownList1.SelectedIndex = 0) And (DropDownList2.SelectedIndex = 0) And (DropDownList3.SelectedIndex = 0) Then
_filterExpression = "CategoryName = '{0}'"
End If Me.SqlDataSource1.FilterExpression = _filterExpression
End Sub
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
ApplyFilter()
End Sub
But this doesn't seem to work. The FilterExpression doesn't keep the value. I am looking for a way to dynamically change the FilterExpression. Any Ideas or Suggestions?? Thanks.
View 5 Replies
View Related
Feb 7, 2006
Folks,
We have some reports that have optional columns. We have them working very nicely, with the column showing or hiding based on values in the report -- works great.
Except -- when the columns are present, the report spans onto two pages, when exported to PDF, in width. That's understandable, as there's a lot of extra data, and exactly what we want. However, when the columns are not present, we get empty pages instead, because the report doesn't automatically contract back onto the size that fits on one page.
Changing the report to a Matrix won't work, as the hidden columns on some of these come as sets of three, where each column in the three has different formatting (different widths, format codes, etc).
Thanks!
--randy
View 14 Replies
View Related
May 10, 2006
Hi all,
I've created 1 solution and added all my packages in different projects (like DIMENSIONS, SOURCES_SAP, ...).
For each project I have a Data Source that connects to the server. The problem is that when I want to deploy a package to the server that I always need to change the Data Source before deployment.
Before SQL Server 2005 we used a connection file (which was located as well on the server as on the development pc's in the same locations) within our DTS packages. This way we didn't had to change the connections when deploying to the server.
My intention was to use the current configuration from the configuration manager(development / production) to select the servername. Unfortunately, I didn't succeed to retrieve it's value from a variable script.
I need to have a solution that dynamically changes the datasources for multiple packages depending on a specific action.
How can I achieve this the easiest way ?
Thanks in advance !
Geert
View 1 Replies
View Related
Sep 23, 2006
Is there a way I can build a case statment or similar to handle different where conditions?
I know I can do it dynamic sql but it would be nice to have a method where I can create the querries directly in a normal statement
Someting like:
Select c1, c2, c3
From Table
WHERE Case @Condition
WHEN '>' @SelColumn > @Limit
WHEN '=' @SelColumn = @Limit
WHEN '<' @SelColumn < @Limit
END
I know this doesn't work so an example that do work would be nice.
View 8 Replies
View Related
Nov 30, 2007
Hi All,
I have a series of tables need to import to server. When creating the target tables, I want to change the columns name as well, for example:
Source table column Target table column
Name FN_Name
Age FN_Age
The problem is I suppose I don't know the columns name in source table, I want to the tasks scan the source table and make the change programmlly.
Which tasks or approaches can be used to implement this?
Thanks
Micror
View 6 Replies
View Related
Oct 26, 2006
I'm sure I'm missing something. I am returning the TOP X number of customers by revenue and I'd like to change the number of records returned by passing a parameter but I keep getting an error. @TopX int ( or varchar) SELECT @TopX CompanyName, Amount FROM Sales Where..... Why will this not work?
View 4 Replies
View Related
Nov 8, 2007
Hello
I have a gridview that I use on a products page, my problems is certain products have different attributes that I would like to display.
Therefore what I would like to do is change the SelectCommand property to my SQLDatasource depending on the querystring that is passed.
For instance in my page load event I would have a CASE statement with numerous SQLString Variables.
Here is the current coding for my datasource
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT PS.ProductSizeMM AS [Coupling Size], PS.ProductWallThickness AS [To Suit], PS.Cost AS [Price], PS.Sold_By AS [Sold by] FROM tblProduct AS P INNER JOIN tblProductSize AS PS ON P.ProductCode = PS.ProductCode WHERE (P.ProductDescription = @ProductDescription) ORDER BY PS.Sorter">
<SelectParameters>
<asp:QueryStringParameter Name="ProductDescription" QueryStringField="ProductDescription" />
</SelectParameters>
</asp:SqlDataSource>I have tried declaring a string variable in my page load event (SQLString) then setting the
SelectCommand="SQLString" but this causes a syntax error
Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near 'SQLString'.
Any help would be greatly appreicated!!
View 3 Replies
View Related
Feb 26, 2014
I have to change the name of the history table dynamically to what is passed in the start date.
If @start_date= '1/1/2014' then it should be history_jan14
If @start_date ='02/01/2014' then it should be history_feb14 and so on.
Is there a way you can do it ?I am using SQL Server 2008.
Code :
DECLARE @start_date datetime
DECLARE @end_date datetime
SET @start_date = '01/01/2014'
SET @end_date = '02/01/2014'
[code]...
View 2 Replies
View Related
Mar 19, 2007
Hi,
I'm novice to SSIS and looking for some help on SSIS dtexec (SQL Server 2005).
Is it possible to change the BulkInsertTableName when running a package via dtexec /SET?
My test scenario contains:
- SQLServer 2005 SP2, servername: SDPM01, instancename: GWLINST1, databasename 1: TEST, databasename 2: DEV, tablename 1: Test_Table1 (both in TEST and DEV database), tablename 2: Test_Table2 (both in TEST and DEV database)
- 1 Data Flow task in BIDS (SSIS)
- 1 Data Flow Source: Flat File Source (Flat File Connection Manager name: FTP File Output + CSV file with a few lines of data that needs to be inserted in a SQL Server table)
- 1 Data Flow Destination: SQL Server Destination (OLE DB Connection Manager name: SDPM01GWLINST1.TEST
I can dynamically change the name of the database via:
DTExec /F "Package.dtsx" /SET "Package.Connections[SDPM01GWLINST1.TEST].InitialCatalog;DEV"
How can I also dynamically change the table name where the data from the CSV file will be inserted?
DTExec /F "Package.dtsx" /SET ...
Thanks in advance,
Geert
View 8 Replies
View Related
Mar 20, 2006
Hi Guys,
This is Ravi. I'm working on SSIS 2005 version. I have created the DTSX file from the SQL Server and executed it successfully from my .NET 2005 code.
Now I have a requirement that I need to dynamically change the Source database query. ie., based on the user selection I need to get the data from different tables of SQL and put it into an Excel file.
Can anyone help me in this..
Regards,
Ravi K. Kalyan
Mascon Global Limited.
View 2 Replies
View Related
Aug 25, 2005
I have a problem using the table object. I have columns that I sometimes want to show, and I want the page to run off the edge and be two pages. However, usually I'm hiding many of the columns and the table "shrinks" enough to fit on one page. When this happens, the table looks right on the first page, but I get blank pages after it, because the report itself will not shrink.
View 4 Replies
View Related
Jan 23, 2008
Hello everyone.
You may had this problem before and know how to do that or may be can suggest me with some ideas.
I am in a process of creating a report wich has 3 groups and the data at the moment grouped by Company - Product - Customer.
I want to be able to change grouping order and respectively the data in report , something like Product - Company - Customer or Customer - Product- Company. (just example)
Is that possible to do at all?
May I add some drag and drop functionality and integrate in my report ?
Any ideas will be most welcomed
Thanks in advance
View 6 Replies
View Related
Mar 7, 2007
Hi,
say I have two Sqldatasources objects:SqlDataSource1 and SqlDataSource2....
Does anybody know how can I alter programmatically these two sqldatasources in a gridview?
Thanks!!!
View 3 Replies
View Related
May 21, 2007
I am a relative newbie to SSIS. I have been tasked with writing packages to import data from our clients. We have about 100 clients. Each client has a few different file formats. None of the clients have the same format as each other. We load files from each client each day. Each day the file name changes. I have done all of my current development work with a constant file name in a text file connection manager.
Ultimately we will write a VB application for the computer operator to select the flat file to load and the SSIS package to load it with. I had been planning on accomplishing this thru the SSIS command line interface. Can I specify the flat file to load via a variable that is passed through the command line? Do I need to use a Script Component to take the variable and assign it to the connection manager?
Is there a better way to do this? I have seen glimpses of a VB interface to SSIS. Maybe that is a better way to kick off the packages from a VB app?
Thanks,
Chris
View 9 Replies
View Related
Oct 4, 2007
I am using Sql Server 2000.
I have about 25+ databases . I want to run a series of commands on each database... how can I change the database context - the current database - dynamically in a loop...
something like this below:
declare @SQLString Nvarchar(1000)
declare @DBName Nvarchar(100)
declare @SQL2 NVARCHAR(1000)
declare @TABLE_NAME NVarchar(100)
While @@FETCH_STATUS=0
Begin
SET @SQL2 = 'USE ' + @DB_NAME + ';GO;ALTER TABLE ' + @TABLE_NAME + ' MODIFY Name varchar(100)'
PRINT @SQL2
EXECUTE SP_EXECUTESQL @SQL2
End
I am getting an error when i run the above commands:
Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'GO'
Can someone give me the correct solution?
View 4 Replies
View Related
Jun 8, 2006
To be clear:
You have a store procedure and inside you make Updates or Inserts against another Server. But that name can change and I dont want to change it manually in everyplace.
Per example:
SELECT *
FROM Himalaya.DBName.dbo.tblUserGroup
WHERE fldUserID = 7300
I have several Selects, Updates and Inserts pointing to that server.
What I can do if I want to change from Himalaya server to another server?
The same with the Database Name.
Thank you
View 6 Replies
View Related
Jul 10, 2006
Hello,
I would like to modify "Files" attribute of the Foreach Loop of type File
Enumerator. This attribute is used to set the mask (for example *.txt) to
specify which files to include in the selection. I need to be able to change
this mask dynamically depending on package global variable. Is this possible?
Thank you!
Michael
View 3 Replies
View Related
Jan 21, 2008
Hello All,
I have designed some reports and kept these reports in the report server.
My question is: I want to change report header and footer values dynamically and save the new values in the report template, when the user enters new velues in ASP.NET GUI.
Next time if the user opens the same file the report should display the recent values.
Please help me in passing the parameters from ASP.NET app to SQL Reports and saving the parameters in the report template.
Thanks,
Rao.
View 6 Replies
View Related
Feb 8, 2006
Hello,
On a 64bit Itanium cluster, I'm having a problem dynamically setting the ConnectionString of a TextFile Source using the "EvaluateAsExpression" = True and setting the ConnectionString using an expression from a variable. I get the error message:
-1073647612,0x,The result of the expression "@[User::vFullFilePath]" on property "ConnectionString" cannot be written to the property. The expression was evaluated, but cannot be set on the property.
This is not a problem at all on a 32bit machine. I can run the same package on 32bit and it runs fine.
The funny thing is, I'm able to dynamically change the ConnectionString of a Logfile that we're writing all of the errors to, which I believe is using a TextFile Destination connection under the covers somehow (I'm using the SSIS Logging, to a textfile).
Can anyone confirm if this is a problem in 64bit?
Thanks,
Andy
View 1 Replies
View Related