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

Sunday, March 25, 2012

Changing the default database files path fails

i have the following code segment which works fine as is:

try

{

ServerConnection connection = new ServerConnection("localhost");

Server server = new Server(connection);

if (!server.Databases.Contains("SMO_TEST"))

{

Database database = new Database(server, "SMO_TEST");

//FileGroup fileGroup = new FileGroup(database, "PRIMARY");

//database.FileGroups.Add(fileGroup);

//DataFile dataFile = new DataFile(fileGroup, "SMO_TEST_Data");

//dataFile.FileName = "D:\\SMO_TEST_Data.mdf";

//fileGroup.Files.Add(dataFile);

//LogFile logFile = new LogFile(database, "SMO_TEST_Log");

//logFile.FileName = "D:\\SMO_TEST_Log.ldf";

//database.LogFiles.Add(logFile);

database.Create();

}

}

catch (FailedOperationException ex)

{

Console.WriteLine(ex.Message);

}

when i uncomment the lines commented above it fails.

Any help?

Fails with which error ?

Jens K. Suessmeyer

http://www.sqlserver2005.de
|||

hi Jenz

thanks for your reply. the code posted earlier worked smoothly just after a computer restart.the error message was either

"Create failed for Database 'SMO_TEST'." or "Drop failed for Database 'SMO_TEST'." with whatever mistake i made, which provided no help in correcting the problem.

however another issue arised when i tried to use a transaction using either method connection.BeginTransaction(); or server.ConnectionContext.BeginTransaction();

(1) how to correct this problem? and

(2) what kind of transaction occures here? is it a distributed transaction?

also i would like to ask

(3)if there is any way to diable full text indexing other than using

connection.ExecuteNonQuery(databaseName + ".dbo.sp_fulltext_database @.action = 'disable'");?(see the code below) .

sql server management studio creates the database with full text indexing disabled by default. but when using smo it is enabled by default and the documentation claims the opposite.

(4) so where does smo take its default values from?

string sqlServerInstance = "localhost";

string databaseName = "SMO_TEST";

string dataFileLogicalName = databaseName + "_Data";

string logFileLogicalName = databaseName + "_Log";

string dataFilePhysicalName = dataFileLogicalName + ".mdf";

string logFilePhysicalName = logFileLogicalName + ".ldf";

string dataFilePath = "D:\\TEST_DIR\\";

string logFilePath = "D:\\TEST_DIR\\";

if (!Directory.Exists(dataFilePath))

{

Directory.CreateDirectory(dataFilePath);

//throw new DirectoryNotFoundException("The data file directory " + dataFilePath + " does not exists.");

}

if (!Directory.Exists(logFilePath))

{

Directory.CreateDirectory(logFilePath);

//throw new DirectoryNotFoundException("The log file directory " + logFilePath + " does not exists.");

}

string defaultFileGroupName = "PRIMARY";

ServerConnection connection;

connection = new ServerConnection(sqlServerInstance);

Server server = new Server(connection);

try

{

//connection.BeginTransaction();

server.ConnectionContext.BeginTransaction();

if (server.Databases.Contains(databaseName))

{

server.Databases[databaseName].Drop();

server.Alter();

}

Database database = new Database(server, databaseName);

FileGroup fileGroup = new FileGroup(database, defaultFileGroupName);

database.FileGroups.Add(fileGroup);

DataFile dataFile = new DataFile(fileGroup, dataFileLogicalName);

dataFile.FileName = dataFilePath + dataFilePhysicalName;

dataFile.GrowthType = FileGrowthType.KB;

dataFile.Growth = 1024d;

fileGroup.Files.Add(dataFile);

LogFile logFile = new LogFile(database, logFileLogicalName);

logFile.FileName = logFilePath + logFilePhysicalName;

logFile.GrowthType = FileGrowthType.Percent;

logFile.MaxSize = 2147483648d;

database.LogFiles.Add(logFile);

database.Create();

// disable full text indexing

connection.ExecuteNonQuery(databaseName + ".dbo.sp_fulltext_database @.action = 'disable'");

//connection.CommitTransaction();

server.ConnectionContext.CommitTransaction();

}

catch (FailedOperationException ex)

{

//connection.RollBackTransaction();

server.ConnectionContext.RollBackTransaction();

Console.WriteLine(ex.Message);

}

finally

{

if (connection != null)

{

if (connection.IsOpen)

{

connection.Disconnect();

}

connection = null;

}

}

thanks again

|||<P align=left><FONT face=Arial size=2>1) Some commands cannot be used within a transaction, but the problem in your case is that the database seems to be in use during the dropping action, see the blog post on my site for more information about that:<BR><BR>2) local one<BR><BR>3) DId not see anything for that, SMO tell that this functionality is deprecated in further versions.</FONT></P>
<P align=left>&nbsp;</P>
<P align=left>4) Which values do you mean ? Some are coded in the SMO library, some are taken from the db system.</P>
<P dir=ltr style="MARGIN-RIGHT: 0px" align=left><BR><BR>Jens K. Suessmeyer<BR><BR><BR><A href="http://www.sqlserver2005.de">http://www.sqlserver2005.de</A><BR></P>|||

Waleed,

You need to add the data and log files before you can assign the filename properties. Try the code here (I've adjusted your code):

try
{
ServerConnection connection = new ServerConnection("localhost");
Server server = new Server(connection);

if (!server.Databases.Contains("SMO_TEST"))
{

Database database = new Database(server, "SMO_TEST");

FileGroup fileGroup = new FileGroup(database, "PRIMARY");
database.FileGroups.Add(fileGroup);
DataFile dataFile = new DataFile(fileGroup, "SMO_TEST_Data");
fileGroup.Files.Add(dataFile);
dataFile.FileName = "D:\\SMO_TEST_Data.mdf";
LogFile logFile = new LogFile(database, "SMO_TEST_Log");
database.LogFiles.Add(logFile);
logFile.FileName = "D:\\SMO_TEST_Log.ldf";
database.Create();
}
}
catch (FailedOperationException ex)
{
Console.WriteLine(ex.Message);
}

|||

dear MVPs,

I tried to loop through the inner exception of the failedOperationException and it turned out that the problem is that Database.Create(), Database.Drop() and

connection.ExecuteNonQuery(databaseName + ".dbo.sp_fulltext_database @.action = 'disable'");

cannot be contained in a transaction

this answers my question about transactions

thank you very much

Thursday, March 22, 2012

Changing the ConnectionString property for a File Connection Manager

I have a package that I plan to run against about 700 databases to look for anomalies. I have several package variables in place that are passed in at runtime. One of them will hold the path and filename of the error log for the current database in process. I want each database to generate it's own error log for documentation and research purposes. However, when I run the package, it continues to use the path and filename that I entered when I created the File Connection Manager. I am trying to update that value in a Script Task by using the ConnectionManager class and setting the value for the "ConnectionString" property. This method is working for the OLEDB Connection Manager (which tells the package which Access database to process), but not for my File Connection Manager. Please help!

DO

Don't try and use a script task to do this. Use expressions: http://blogs.conchango.com/jamiethomson/archive/2006/03/11/3063.aspx

-Jamie

|||Thanks, you've done it again.

Changing the connection string on the fly....

Now that I have figured out how to connect to a foxpro database...

Could anyone tell me how to change the connection string on the fly?

I would like to make it possible, from the command line (using dtexec) to specify a portion of the connection string.... incorportate this portion into the connection string and then instruct the connection manager to use this connection...

For example I have a number of foxpro databases to import, they will be place in a directory structure like this:

TopLevel
TopLevel\NewYork\transactions.dbf
TopLevel\London\transactions.dbf
TopLevel\Sydney\transactions.dbf

I'd like the user to be able to specify which city's files to load each time the package is run..

dtexec /f MyPackage /set \Package.Variables[User::THECITY].Properties[Value];"London"

And when the package starts the THECITY variable would take the value "London"

But I'm not sure how to then affect the connection string property of the connection manager... there seems to be no way to specify that it take its connection string property from an expression...

So I'm lookin for some way which would cause the Connection String property of the coneection manager to become:
Driver={Microsoft Visual FoxPro Driver};sourcedb=d:\TopLevel\London;sourcetype=DBF;exclusive=No;backgroundfetch=Yes;collate=Machine;

Jsut to recap, the provider for this connection manager
is a ".Net Providers\Odbc Data Provider" which I've been forced to use becasue the OLEDb provider for Foxpro has been rendered useless by service pack 1

Thanks in advance
PJ

PJFINTRAX wrote:

Now that I have figured out how to connect to a foxpro database...

Could anyone tell me how to change the connection string on the fly?

I would like to make it possible, from the command line (using dtexec) to specify a portion of the connection string.... incorportate this portion into the connection string and then instruct the connection manager to use this connection...

For example I have a number of foxpro databases to import, they will be place in a directory structure like this:

TopLevel
TopLevel\NewYork\transactions.dbf
TopLevel\London\transactions.dbf
TopLevel\Sydney\transactions.dbf

I'd like the user to be able to specify which city's files to load each time the package is run..

dtexec /f MyPackage /set \Package.Variables[User::THECITY].Properties[Value];"London"

And when the package starts the THECITY variable would take the value "London"

But I'm not sure how to then affect the connection string property of the connection manager... there seems to be no way to specify that it take its connection string property from an expression...

So I'm lookin for some way which would cause the Connection String property of the coneection manager to become:
Driver={Microsoft Visual FoxPro Driver};sourcedb=d:\TopLevel\London;sourcetype=DBF;exclusive=No;backgroundfetch=Yes;collate=Machine;

Jsut to recap, the provider for this connection manager
is a ".Net Providers\Odbc Data Provider" which I've been forced to use becasue the OLEDb provider for Foxpro has been rendered useless by service pack 1

Thanks in advance
PJ

PJ,

It is eminently possible to put an expression onto the ConnectionString property of a connection manager. You need to access the Expressions UI via the proeprties window.

In this example you can also use the /CONN option of dtexec. Check that out as well.

-Jamie

|||Hi Jamie,
thanks for the reply...
Mustn't have had enough caffeine in my system...

I was right clicking on the connection manager and selecting 'Edit'.. and there's no way there to set up an expression to populate the connection string....
Of course I completely forgot about the properties window... with the ..sigh.. Expressions option ... right there... sigh...

Apologies...

PJ

changing TCP/IP port breaks "local" connection

Hi All:
I wanted to change the TCP/IP port a default instance of SQL was
running on (from 1433 to something random like 49576) on Win2K AS
(sp4+). SQL's got TCP/IP and NamedPipes libraries active. I believe
MDAC 2.8 is installed.
The server has a base IP of 192.168.1.190 and a website running on
192.168.1.191. The website uses a SQL0LEDB.1 connection to the
database using "local" for the server name.
This all runs fine when the SQL server's on 1433, but if I change it
to another port, it breaks the connection from the website to the SQL
server. Restarting services doesn't help, even rebooting doesn't
restore the connection. If I switch the SQL Server back to 1433 it
runs fine.
I tested the same thing on a server running Win2003, and the website
didn't have a problem connecting to the SQL server when I changed the
TCP/IP port.
Any ideas why this breaks on Win2K?
TIA
check 1434
and
delete
HKLM\software\microsoft\mssqlserver\client\superso cketnetlib\lastconnect key
<sql server name or ip>
"vze78se7@.verizon.net" wrote:

> Hi All:
> I wanted to change the TCP/IP port a default instance of SQL was
> running on (from 1433 to something random like 49576) on Win2K AS
> (sp4+). SQL's got TCP/IP and NamedPipes libraries active. I believe
> MDAC 2.8 is installed.
> The server has a base IP of 192.168.1.190 and a website running on
> 192.168.1.191. The website uses a SQL0LEDB.1 connection to the
> database using "local" for the server name.
> This all runs fine when the SQL server's on 1433, but if I change it
> to another port, it breaks the connection from the website to the SQL
> server. Restarting services doesn't help, even rebooting doesn't
> restore the connection. If I switch the SQL Server back to 1433 it
> runs fine.
> I tested the same thing on a server running Win2003, and the website
> didn't have a problem connecting to the SQL server when I changed the
> TCP/IP port.
> Any ideas why this breaks on Win2K?
> TIA
>
|||On Mon, 24 Jan 2005 06:05:04 -0800, "Aleksandar Grbic"
<AleksandarGrbic@.discussions.microsoft.com> wrote:

>check 1434
Thanks, Alexsandar. What do you mean by "check 1434"? I have TCP/UDP
1434 disabled because I don't want to broadcast or receive on the
"slammer" port.

>and
>delete
>HKLM\software\microsoft\mssqlserver\client\supers ocketnetlib\lastconnect key
><sql server name or ip>
I will try that, thanks.
[vbcol=seagreen]
>"vze78se7@.verizon.net" wrote:
|||
>check 1434
>and
>delete
>HKLM\software\microsoft\mssqlserver\client\supers ocketnetlib\lastconnect key
><sql server name or ip>
>
One other question...Can I avoid this problem by using Named Pipes?
I will only ever be connecting to the local machine from this
website. I thought using "(local)" for the server bypassed TCP/IP
altogether?
Or does this problem have nothing to do with TCP/IP?
|||configure alias in client network utility on client
make alias for sql server in alias tab, write sql server alias, sql name and
tcp/ip port
or
make alias with named pipe
"vze78se7@.verizon.net" wrote:

>
> One other question...Can I avoid this problem by using Named Pipes?
> I will only ever be connecting to the local machine from this
> website. I thought using "(local)" for the server bypassed TCP/IP
> altogether?
> Or does this problem have nothing to do with TCP/IP?
>

changing TCP/IP port breaks "local" connection

Hi All:
I wanted to change the TCP/IP port a default instance of SQL was
running on (from 1433 to something random like 49576) on Win2K AS
(sp4+). SQL's got TCP/IP and NamedPipes libraries active. I believe
MDAC 2.8 is installed.
The server has a base IP of 192.168.1.190 and a website running on
192.168.1.191. The website uses a SQL0LEDB.1 connection to the
database using "local" for the server name.
This all runs fine when the SQL server's on 1433, but if I change it
to another port, it breaks the connection from the website to the SQL
server. Restarting services doesn't help, even rebooting doesn't
restore the connection. If I switch the SQL Server back to 1433 it
runs fine.
I tested the same thing on a server running Win2003, and the website
didn't have a problem connecting to the SQL server when I changed the
TCP/IP port.
Any ideas why this breaks on Win2K?
TIAcheck 1434
and
delete
HKLM\software\microsoft\mssqlserver\client\supersocketnetlib\lastconnect key
<sql server name or ip>
"vze78se7@.verizon.net" wrote:
> Hi All:
> I wanted to change the TCP/IP port a default instance of SQL was
> running on (from 1433 to something random like 49576) on Win2K AS
> (sp4+). SQL's got TCP/IP and NamedPipes libraries active. I believe
> MDAC 2.8 is installed.
> The server has a base IP of 192.168.1.190 and a website running on
> 192.168.1.191. The website uses a SQL0LEDB.1 connection to the
> database using "local" for the server name.
> This all runs fine when the SQL server's on 1433, but if I change it
> to another port, it breaks the connection from the website to the SQL
> server. Restarting services doesn't help, even rebooting doesn't
> restore the connection. If I switch the SQL Server back to 1433 it
> runs fine.
> I tested the same thing on a server running Win2003, and the website
> didn't have a problem connecting to the SQL server when I changed the
> TCP/IP port.
> Any ideas why this breaks on Win2K?
> TIA
>|||On Mon, 24 Jan 2005 06:05:04 -0800, "Aleksandar Grbic"
<AleksandarGrbic@.discussions.microsoft.com> wrote:
>check 1434
Thanks, Alexsandar. What do you mean by "check 1434"? I have TCP/UDP
1434 disabled because I don't want to broadcast or receive on the
"slammer" port.
>and
>delete
>HKLM\software\microsoft\mssqlserver\client\supersocketnetlib\lastconnect key
><sql server name or ip>
I will try that, thanks.
>"vze78se7@.verizon.net" wrote:
>> Hi All:
>> I wanted to change the TCP/IP port a default instance of SQL was
>> running on (from 1433 to something random like 49576) on Win2K AS
>> (sp4+). SQL's got TCP/IP and NamedPipes libraries active. I believe
>> MDAC 2.8 is installed.
>> The server has a base IP of 192.168.1.190 and a website running on
>> 192.168.1.191. The website uses a SQL0LEDB.1 connection to the
>> database using "local" for the server name.
>> This all runs fine when the SQL server's on 1433, but if I change it
>> to another port, it breaks the connection from the website to the SQL
>> server. Restarting services doesn't help, even rebooting doesn't
>> restore the connection. If I switch the SQL Server back to 1433 it
>> runs fine.
>> I tested the same thing on a server running Win2003, and the website
>> didn't have a problem connecting to the SQL server when I changed the
>> TCP/IP port.
>> Any ideas why this breaks on Win2K?
>> TIA|||>check 1434
>and
>delete
>HKLM\software\microsoft\mssqlserver\client\supersocketnetlib\lastconnect key
><sql server name or ip>
>
One other question...Can I avoid this problem by using Named Pipes?
I will only ever be connecting to the local machine from this
website. I thought using "(local)" for the server bypassed TCP/IP
altogether?
Or does this problem have nothing to do with TCP/IP?|||configure alias in client network utility on client
make alias for sql server in alias tab, write sql server alias, sql name and
tcp/ip port
or
make alias with named pipe
"vze78se7@.verizon.net" wrote:
> >check 1434
> >and
> >delete
> >HKLM\software\microsoft\mssqlserver\client\supersocketnetlib\lastconnect key
> ><sql server name or ip>
> >
> One other question...Can I avoid this problem by using Named Pipes?
> I will only ever be connecting to the local machine from this
> website. I thought using "(local)" for the server bypassed TCP/IP
> altogether?
> Or does this problem have nothing to do with TCP/IP?
>sql

changing TCP/IP port breaks "local" connection

Hi All:
I wanted to change the TCP/IP port a default instance of SQL was
running on (from 1433 to something random like 49576) on Win2K AS
(sp4+). SQL's got TCP/IP and NamedPipes libraries active. I believe
MDAC 2.8 is installed.
The server has a base IP of 192.168.1.190 and a website running on
192.168.1.191. The website uses a SQL0LEDB.1 connection to the
database using "local" for the server name.
This all runs fine when the SQL server's on 1433, but if I change it
to another port, it breaks the connection from the website to the SQL
server. Restarting services doesn't help, even rebooting doesn't
restore the connection. If I switch the SQL Server back to 1433 it
runs fine.
I tested the same thing on a server running Win2003, and the website
didn't have a problem connecting to the SQL server when I changed the
TCP/IP port.
Any ideas why this breaks on Win2K?
TIAcheck 1434
and
delete
HKLM\software\microsoft\mssqlserver\clie
nt\supersocketnetlib\lastconnect ke
y
<sql server name or ip>
"vze78se7@.verizon.net" wrote:

> Hi All:
> I wanted to change the TCP/IP port a default instance of SQL was
> running on (from 1433 to something random like 49576) on Win2K AS
> (sp4+). SQL's got TCP/IP and NamedPipes libraries active. I believe
> MDAC 2.8 is installed.
> The server has a base IP of 192.168.1.190 and a website running on
> 192.168.1.191. The website uses a SQL0LEDB.1 connection to the
> database using "local" for the server name.
> This all runs fine when the SQL server's on 1433, but if I change it
> to another port, it breaks the connection from the website to the SQL
> server. Restarting services doesn't help, even rebooting doesn't
> restore the connection. If I switch the SQL Server back to 1433 it
> runs fine.
> I tested the same thing on a server running Win2003, and the website
> didn't have a problem connecting to the SQL server when I changed the
> TCP/IP port.
> Any ideas why this breaks on Win2K?
> TIA
>|||On Mon, 24 Jan 2005 06:05:04 -0800, "Aleksandar Grbic"
<AleksandarGrbic@.discussions.microsoft.com> wrote:

>check 1434
Thanks, Alexsandar. What do you mean by "check 1434"? I have TCP/UDP
1434 disabled because I don't want to broadcast or receive on the
"slammer" port.

>and
>delete
> HKLM\software\microsoft\mssqlserver\clie
nt\supersocketnetlib\lastconnect k
ey
><sql server name or ip>
I will try that, thanks.
[vbcol=seagreen]
>"vze78se7@.verizon.net" wrote:
>|||
>check 1434
>and
>delete
> HKLM\software\microsoft\mssqlserver\clie
nt\supersocketnetlib\lastconnect k
ey
><sql server name or ip>
>
One other question...Can I avoid this problem by using Named Pipes?
I will only ever be connecting to the local machine from this
website. I thought using "(local)" for the server bypassed TCP/IP
altogether?
Or does this problem have nothing to do with TCP/IP?|||configure alias in client network utility on client
make alias for sql server in alias tab, write sql server alias, sql name and
tcp/ip port
or
make alias with named pipe
"vze78se7@.verizon.net" wrote:

>
> One other question...Can I avoid this problem by using Named Pipes?
> I will only ever be connecting to the local machine from this
> website. I thought using "(local)" for the server bypassed TCP/IP
> altogether?
> Or does this problem have nothing to do with TCP/IP?
>

Wednesday, March 7, 2012

Changing Parameter in SQLDataSource for Multiple DropDowns

I have one page, one connection, and three dropdowns.
The connection looks like (as an example):

<asp:SqlDataSource ID="DropDownConn" runat="server" ConnectionString="<%$ ConnectionStrings:aousConnectionString %>"
SelectCommand="SELECT [Value], [Text] FROM [DropDown] WHERE (([Group] = @.Group) AND ([Viewable] = @.Viewable))">
<SelectParameters>
<asp:Parameter Name="Group" Type="String" />
<asp:Parameter DefaultValue="True" Name="Viewable" Type="Boolean" />
</SelectParameters>
</asp:SqlDataSource>

The DropDowns Look like this:

<asp:DropDownList ID="DropDown1" runat="server"></asp:DropDownList>
<asp:DropDownList ID="DropDown2" runat="server"></asp:DropDownList>
<asp:DropDownList ID="DropDown3" runat="server"></asp:DropDownList
The C# Code I am trying is like this:
DropDownConn.SelectParameters["Group"].Equals("DropDown1");
DropDownConn.SelectParameters["Viewable"].Equals(true);
DropDown1.DataSourceID = "DropDownConn";
DropDown1.DataTextField = "Text";
DropDown1.DataValueField = "Value";
DropDown1.DataBind();

As an example. I can not get it done so that I don't have to create 3 dataconnections. Any help, PLEASE?

It should be done this way..

DropDownConn.SelectParameters["Group"].DefaultValue = "some group value"; // change it accordingly on what data should be displayed in the dropdownlists
DropDownConn.SelectParameters["Viewable"].DefaultValue = "True";

DropDown1.DataSource = DropDownConn;
DropDown1.DataTextField = "Text";
DropDown1.DataValueField = "Value";
DropDown1.DataBind();

// for second

DropDownConn.SelectParameters["Group"].DefaultValue = "some group value for second dropdown"; // change it accordingly on what data should be displayed in the dropdownlists
DropDownConn.SelectParameters["Viewable"].DefaultValue = "True";

DropDown2.DataSource = DropDownConn;
DropDown2.DataTextField = "Text";
DropDown2.DataValueField = "Value";
DropDown2.DataBind();

-----

You can also, refactor the code to set the datasource for the dropdownlist.

Thanks

-Mark post(s) as "Answer" that helped you

|||

Thank you for the answer, and that method does work. Is that really the way we are suppose to do it. The default value is such a poor naming scheme and Microsoft had done such a good job with most other things. Thanks for the the help.

Thursday, February 16, 2012

Changing flat file connection file name property

Hi,

I have a task to traverse a folder of CSV files of same format and then populate into one sql server table.

Is there a way where I can change the source CSV file name runtime using FOR EACH loop container for flat file connection manager ?

any help would be much appriciated.

Thanks,

Furrukh Baig

Yes. By using package expressions. There is an example in the SSIS tutorials that I think does exactly what you want to do assuming all files are in the same directory.|||Thanks mate... you are star ...|||

I'm also trying to do the same thing, except that each folder has a number of different csv files. Would appreciate if someone could give me a link of the sample (as mentioned in the previous post) and whether it's better to have different flat file source for each type of csv file format or should I just use 1 flat file source.

I've tried using 1 flat file source but the number of columns are different for each files and the number of columns in the flat file source isn't dynamic (I've to prespecify it first).

|||I'm assuming you're talking about the foreach loop container in the tutorial (ms-help://MS.VSCC.v80/MS.VSIPCC.v80/MS.SQLSVR.v9.en/sqltut9/html/88a973cc-0f23-4ecf-adb6-5b06279c2df6.htm) Can you use a similar concept to loop thru xml files? I have an xml source, 2 sorts and a merge-join. Whenever I change the input file, I need to open my sorts and click ok. How will that work if I need to iterate thru a directory of files?

Changing flat file connection file name property

Hi,

I have a task to traverse a folder of CSV files of same format and then populate into one sql server table.

Is there a way where I can change the source CSV file name runtime using FOR EACH loop container for flat file connection manager ?

any help would be much appriciated.

Thanks,

Furrukh Baig

Yes. By using package expressions. There is an example in the SSIS tutorials that I think does exactly what you want to do assuming all files are in the same directory.|||Thanks mate... you are star ...|||

I'm also trying to do the same thing, except that each folder has a number of different csv files. Would appreciate if someone could give me a link of the sample (as mentioned in the previous post) and whether it's better to have different flat file source for each type of csv file format or should I just use 1 flat file source.

I've tried using 1 flat file source but the number of columns are different for each files and the number of columns in the flat file source isn't dynamic (I've to prespecify it first).

|||I'm assuming you're talking about the foreach loop container in the tutorial (ms-help://MS.VSCC.v80/MS.VSIPCC.v80/MS.SQLSVR.v9.en/sqltut9/html/88a973cc-0f23-4ecf-adb6-5b06279c2df6.htm) Can you use a similar concept to loop thru xml files? I have an xml source, 2 sorts and a merge-join. Whenever I change the input file, I need to open my sorts and click ok. How will that work if I need to iterate thru a directory of files?

Changing Domain Password loses Enterprise Manager UID's

When anyone at work changes their domain password they lose all their Enterp
rise Manager server connection details too. Is there a fix for this besides
backing up chunks of the registry ? (Each month the users are forced to chan
ge their passwords and this
really raises their ire on the matter...
Many thanks
ChrisThe following article may address your problem.
http://support.microsoft.com/?id=323280
Based on the nature of the problem service pack 3 for SQL Server 2000 needs
to be applied on the client machines affected by this.
Rand
This posting is provided "as is" with no warranties and confers no rights.

Sunday, February 12, 2012

Changing DB connection from SqlServer to Oracle

Hi

I am trying to switch between oracle and sqlserver databases to read the source data. I have used a parameter file to specify the connection parameters. For SQLserver the connection looks like in the file as below:

<?xml version="1.0"?><DTSConfiguration><DTSConfigurationHeading><DTSConfigurationFileInfo GeneratedBy="ab\vsh" GeneratedFromPackageName="Package" GeneratedFromPackageID="{8A304BF7-5325-4079-9D92-2B9BBF8793AA}" GeneratedDate="1/23/2007 4:46:08 PM"/></DTSConfigurationHeading><Configuration ConfiguredType="Property" Path="\Package.Connections[dl.PM_DW].Properties[ConnectionString]" ValueType="String"><ConfiguredValue>Data Source=dl;Initial Catalog=PM_DW;Provider=SQLNCLI.1;Integrated Security=SSPI;Auto Translate=False;</ConfiguredValue></Configuration><Configuration ConfiguredType="Property" Path="\Package.Connections[dl.PM_DW].Properties[Description]" ValueType="String"><ConfiguredValue></ConfiguredValue></Configuration><Configuration ConfiguredType="Property" Path="\Package.Connections[dl.PM_DW].Properties[InitialCatalog]" ValueType="String"><ConfiguredValue>PM_DW</ConfiguredValue></Configuration><Configuration ConfiguredType="Property" Path="\Package.Connections[dl.PM_DW].Properties[Name]" ValueType="String"><ConfiguredValue>dl.PM_DW</ConfiguredValue></Configuration><Configuration ConfiguredType="Property" Path="\Package.Connections[dl.PM_DW].Properties[Password]" ValueType="String"><ConfiguredValue></ConfiguredValue></Configuration><Configuration ConfiguredType="Property" Path="\Package.Connections[dl.PM_DW].Properties[ProtectionLevel]" ValueType="Int32"><ConfiguredValue>1</ConfiguredValue></Configuration><Configuration ConfiguredType="Property" Path="\Package.Connections[dl.PM_DW].Properties[RetainSameConnection]" ValueType="Boolean"><ConfiguredValue>0</ConfiguredValue></Configuration><Configuration ConfiguredType="Property" Path="\Package.Connections[dl.PM_DW].Properties[ServerName]" ValueType="String"><ConfiguredValue>dl</ConfiguredValue></Configuration><Configuration ConfiguredType="Property" Path="\Package.Connections[dl.PM_DW].Properties[UserName]" ValueType="String"><ConfiguredValue></ConfiguredValue></Configuration></DTSConfiguration>

the pacakge runs fine. But when i change the connection to Oracle, it gives me error.

The config file looks like when i put oracle connection is as follows:

<?xml version="1.0"?><DTSConfiguration><DTSConfigurationHeading><DTSConfigurationFileInfo GeneratedBy="I2\vshrivas" GeneratedFromPackageName="Package" GeneratedFromPackageID="{8A304BF7-5325-4079-9D92-2B9BBF8793AA}" GeneratedDate="1/23/2007 4:46:08 PM"/></DTSConfigurationHeading><Configuration ConfiguredType="Property" Path="\Package.Connections[dl.PM_DW].Properties[ConnectionString]" ValueType="String"><ConfiguredValue>Data Source=pm62;User ID=pcm_62;Provider=OraOLEDB.Oracle.1;Persist Security Info=True;</ConfiguredValue></Configuration><Configuration ConfiguredType="Property" Path="\Package.Connections[dl.PM_DW].Properties[Description]" ValueType="String"><ConfiguredValue></ConfiguredValue></Configuration><Configuration ConfiguredType="Property" Path="\Package.Connections[dl.PM_DW].Properties[InitialCatalog]" ValueType="String"><ConfiguredValue></ConfiguredValue></Configuration><Configuration ConfiguredType="Property" Path="\Package.Connections[dl.PM_DW].Properties[Name]" ValueType="String"><ConfiguredValue>dl.PM_DW</ConfiguredValue></Configuration><Configuration ConfiguredType="Property" Path="\Package.Connections[dl.PM_DW].Properties[Password]" ValueType="String"><ConfiguredValue></ConfiguredValue></Configuration><Configuration ConfiguredType="Property" Path="\Package.Connections[dl.PM_DW].Properties[ProtectionLevel]" ValueType="Int32"><ConfiguredValue>1</ConfiguredValue></Configuration><Configuration ConfiguredType="Property" Path="\Package.Connections[dl.PM_DW].Properties[RetainSameConnection]" ValueType="Boolean"><ConfiguredValue>0</ConfiguredValue></Configuration><Configuration ConfiguredType="Property" Path="\Package.Connections[dl.PM_DW].Properties[ServerName]" ValueType="String"><ConfiguredValue>i2pm62</ConfiguredValue></Configuration><Configuration ConfiguredType="Property" Path="\Package.Connections[dl.PM_DW].Properties[UserName]" ValueType="String"><ConfiguredValue>pcm_62</ConfiguredValue></Configuration></DTSConfiguration>

The error which i get when running from oracle source is this:

Information: 0x40016041 at Package: The package is attempting to configure from the XML file "C:\oraTOsql-DataTX\Integration Services Project1\Integration Services Project1\Integration Services Project1\testConfig.dtsConfig".
SSIS package "Package.dtsx" starting.
Information: 0x4004300A at Data Flow Task, DTS.Pipeline: Validation phase is beginning.
Error: 0xC0202009 at Package, Connection manager "dl.PM_DW": An OLE DB error has occurred. Error code: 0x80040E21.
An OLE DB record is available. Source: "Microsoft OLE DB Service Components" Hresult: 0x80040E21 Description: "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.".
Error: 0xC020801C at Data Flow Task, OLE DB Source [1]: The AcquireConnection method call to the connection manager "dl.PM_DW" failed with error code 0xC0202009.
Error: 0xC0047017 at Data Flow Task, DTS.Pipeline: component "OLE DB Source" (1) failed validation and returned error code 0xC020801C.
Error: 0xC004700C at Data Flow Task, DTS.Pipeline: One or more component failed validation.
Error: 0xC0024107 at Data Flow Task: There were errors during task validation.
SSIS package "Package.dtsx" finished: Failure.
The program '[7264] Package.dtsx: DTS' has exited with code 0 (0x0).

Please let me know if you guys have any suggestion in what i am doing wrong.

Thanks,

Vipul

First of all, I highly recommend that you only store the ConnectionString property in the configuration file rather than the constituent parts.

Please could you make that change and see if you get the same problem. If you do, post the before & after contents of the new config file up here - it'll be much easier to read than what you have posted above.

-Jamie

|||

Jamie:

Thanks for the advice. Using only connection string in the configuration file works.

Thanks,

Vipul