Friday, February 17, 2012

DataBase path

How can I create a DataBase with smo in another path?

thanks,

Hi,

you can do that by specifying the new file path witin the datafile object:

DataFile df = new DataFile(new FileGroup("DBName","FileGroupName"),"Logicaldbname",@."C:\Somepathtostore\somefilename.mdf");

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de

|||

Hi Jens,

I want set the local path when create a DataBase. Thats possible?

My code for creating:

Dim wServer As New Server(sSqlServer)

Dim wBDados As New Database(wServer, "DataBase")

wBDados.DatabaseOptions.AutoShrink = True

wBDados.Create()

wBDados.Alter()

Thanks again,

Marsenne

|||

What do yu mean by "local" path ? The pah is always relative to the server you are creating the database on.

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de

|||

local path is the path of database files.

I want create a DataBase and set the files path in another directory.

Sample:

Default path of Sql Server -> C:\SqlServer\DataBases

Path my new DataBase -> C:\SqlServer\DataBases\MyNewDataBase

|||Thats like I wrote you:

DataFile df = new DataFile(new FileGroup("DBName","FileGroupName"),"Logicaldbname",@."C:\SqlServer\DataBases\MyNewDataBase\somefilename.mdf");

If yu want to use a specific directory you have to specify the single filesnames frhe database

HTH, Jens Suessmeyer.

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

I use Visual Basic 2005. The code is not work.

Please, send me complete code for creating database and define the files path.

thanks,

Marsenne

|||

I want modify the path Files of 'Primary' FilesGroup when DataBase is create.

The smo create a default 'primary' FilesGroup when DataBase.Create().

After database is create the path 'primary' FilesGroup' was not change.

Thats possible?

Dim srv as new Server ("SQL instance")

Dim db as new DataBase (srv,"DataBaseTest")

--> how code for modify the FilesGroup 'primary' and the files path?

db.create()

Thanks,

Marsenne

|||

This code below sucessfuly. Create a DataBase in another path (files)

- create a path first (D:\SqlBancos\Teste) with 'primaryroot' databases base.

Dim srv As New Server(Me.cmbSqlServer.Text)

Dim db As New Database(srv, "Teste")

db.DatabaseOptions.AutoShrink = True

db.FileGroups.Add(New FileGroup(db, "PRIMARY"))

db.FileGroups(0).Files.Add(New DataFile(db.FileGroups(0), "TestName", "D:\SqlBancos\Teste\Teste1.mdf"))

db.Create()

db.Alter()

Marsenne Negreiros

No comments:

Post a Comment