SQLDMO attachDB error with filenames including space character

  • Thread starter Thread starter n33470
  • Start date Start date
N

n33470

Hey everyone!

I'm trying to use SQLDMO to programmatically attach a database. I
have a problem when the file name includes a space character, for
example: @"C:\Program Files\Microsoft SQL
Server\MSSQL\Data\DM_0814_ABCTrucking.mdf"

Here's a sample of code:

string tmp = @"C:\Program Files\Microsoft SQL
Server\MSSQL\Data\DM_0814_ABCTrucking.mdf" +"," +@"C:\Program
Files\Microsoft SQL Server\MSSQL\Data\DM_0814_ABCTrucking_log.ldf";

SQLDMO.SQLServer sqlDMOConn = new SQLDMO.SQLServer();

sqlDMOConn.Connect("(local)", "sa", "");

sqlDMOConn.AttachDB( "DM_0814_ABCTrucking", tmp );

When I do this, the AttachDB call raised the following exception
"Device Activation Error. The physical file name 'C:\Program' may be
incorrect."

I think what's happening is that SQLDMO doesn't like the space
character in the filenames. How can I formulate the file name
correctly?

--steve
 
Hey everyone!

I'm trying to use SQLDMO to programmatically attach a database. I
have a problem when the file name includes a space character, for
example: @"C:\Program Files\Microsoft SQL
Server\MSSQL\Data\DM_0814_ABCTrucking.mdf"

Here's a sample of code:

string tmp = @"C:\Program Files\Microsoft SQL
Server\MSSQL\Data\DM_0814_ABCTrucking.mdf" +"," +@"C:\Program
Files\Microsoft SQL Server\MSSQL\Data\DM_0814_ABCTrucking_log.ldf";

SQLDMO.SQLServer sqlDMOConn = new SQLDMO.SQLServer();

sqlDMOConn.Connect("(local)", "sa", "");

sqlDMOConn.AttachDB( "DM_0814_ABCTrucking", tmp );

When I do this, the AttachDB call raised the following exception
"Device Activation Error. The physical file name 'C:\Program' may be
incorrect."

I think what's happening is that SQLDMO doesn't like the space
character in the filenames. How can I formulate the file name
correctly?

--steve

User submitted from AEWNET (http://www.aewnet.com/)
 
Hey everyone!

I'm trying to use SQLDMO to programmatically attach a database. I
have a problem when the file name includes a space character, for
example: @"C:\Program Files\Microsoft SQL
Server\MSSQL\Data\DM_0814_ABCTrucking.mdf"

Here's a sample of code:

string tmp = @"C:\Program Files\Microsoft SQL
Server\MSSQL\Data\DM_0814_ABCTrucking.mdf" +"," +@"C:\Program
Files\Microsoft SQL Server\MSSQL\Data\DM_0814_ABCTrucking_log.ldf";

SQLDMO.SQLServer sqlDMOConn = new SQLDMO.SQLServer();

sqlDMOConn.Connect("(local)", "sa", "");

sqlDMOConn.AttachDB( "DM_0814_ABCTrucking", tmp );

When I do this, the AttachDB call raised the following exception
"Device Activation Error. The physical file name 'C:\Program' may be
incorrect."

I think what's happening is that SQLDMO doesn't like the space
character in the filenames. How can I formulate the file name
correctly?

--steve

User submitted from AEWNET (http://www.aewnet.com/)
 
Hey everyone!
I'm trying to use SQLDMO to programmatically attach a database. I
have a problem when the file name includes a space character, for
example: @"C:\Program Files\Microsoft SQL
Server\MSSQL\Data\DM_0814_ABCTrucking.mdf"

Here's a sample of code:

string tmp = @"C:\Program Files\Microsoft SQL
Server\MSSQL\Data\DM_0814_ABCTrucking.mdf" +"," +@"C:\Program
Files\Microsoft SQL Server\MSSQL\Data\DM_0814_ABCTrucking_log.ldf";

SQLDMO.SQLServer sqlDMOConn = new SQLDMO.SQLServer();

sqlDMOConn.Connect("(local)", "sa", "");

sqlDMOConn.AttachDB( "DM_0814_ABCTrucking", tmp );

When I do this, the AttachDB call raised the following exception
"Device Activation Error. The physical file name 'C:\Program' may be
incorrect."

I think what's happening is that SQLDMO doesn't like the space
character in the filenames. How can I formulate the file name
correctly?

--steve

Hi,

You have jsut to put the string between [ and ] .
exp : yourstringPath = "[c:\\program files\\....]";
for more info go to this link: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sqldmo/dmoref_con01_80j7.asp

Ahmed Akrour.





User submitted from AEWNET (http://www.aewnet.com/)
 
Back
Top