I can't change the database file size with a C# query. For some reason I get an exception: "Incorrect syntax near '@databaseName'.
This is the code that executed the query:
command = connection.CreateCommand();
command.CommandText = @"
ALTER DATABASE @databaseName
MODIFY FILE
(NAME = @databaseFile, SIZE = @newSize)
";
dbParam = command.CreateParameter();
dbParam.ParameterName = "databaseFile";
dbParam.Value = dbFileName;
command.Parameters.Add(dbParam);
dbParam = command.CreateParameter();
dbParam.ParameterName = "newSize";
dbParam.Value = newSize;
command.Parameters.Add(dbParam);
dbParam = command.CreateParameter();
dbParam.ParameterName = "databaseName";
dbParam.Value = databaseName;
command.Parameters.Add(dbParam);
command.ExecuteNonQuery();
Now there might be several problems. Firstly the database is on a different machine so wouldn't the db file path be different?