SQLDMO attachDB error with filenames including space character

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
 
G

Guest

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/)
 
G

Guest

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/)
 
G

Guest

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/)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top