Paul Hemans
2008-04-06 10:00:23 UTC
Hi,
Here's my code:
SqlCommand cmd = new SqlCommand("sp_dboption", sqlConn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@dbname", mdfName);
cmd.Parameters.AddWithValue("@optname", "offline");
cmd.Parameters.AddWithValue("@optvalue", "true");
try
{
cmd.ExecuteNonQuery();
}
catch (SqlException se)
{
return "SQL exception going offline\n" + se.ToString();
}
The problem seems to be that mdfName is "|DataDirectory|\myMdf.mdf". Is it
correct to presume that SQL has converted the |DataDirectory| into a full
path and so my request is no longer valid? Any suggestions for getting
around that?
Here's my code:
SqlCommand cmd = new SqlCommand("sp_dboption", sqlConn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@dbname", mdfName);
cmd.Parameters.AddWithValue("@optname", "offline");
cmd.Parameters.AddWithValue("@optvalue", "true");
try
{
cmd.ExecuteNonQuery();
}
catch (SqlException se)
{
return "SQL exception going offline\n" + se.ToString();
}
The problem seems to be that mdfName is "|DataDirectory|\myMdf.mdf". Is it
correct to presume that SQL has converted the |DataDirectory| into a full
path and so my request is no longer valid? Any suggestions for getting
around that?