SQDLDOM e copia db

lunedì 23 ottobre 2006 - 10.57

memmo77 Profilo | Expert

Ho un problema, sotto riporto il codice che uso per fare la copia di un db, fino al detach tutto ok quando vado a copiare il file, mi dice che non lo trova, ma il file è nel percorso indicato. Da cosa può dipendere? Grazie

Dim sql As Object
Dim db As Object
Dim tb As SQLDMO.Table
Dim strMDFfilePath As String
Dim strMDFfileName As String
Dim strLOGfile As String
Try
'Create Objects
sql = CreateObject("SQLDMO.SQLServer")
db = CreateObject("SQLDMO.Database")

'Connect to the server
'sql.Connect(strSrv, strLogin, strPwd)
sql.Connect(strSrv, txtUserName.Text, txtPass.Text)

'Set the database object
db = sql.Databases(strDatabase, "dbo")

'Determine the location of database files, primary and log
strMDFfilePath = db.PrimaryFilePath
strMDFfileName = Trim(db.FileGroups.Item(1).DBFiles.Item(1).PhysicalName)
strLOGfile = Trim(db.TransactionLog.LogFiles(1).PhysicalName)

'Clear out the database object
db = Nothing

'Detach database to allow copying
sql.DetachDB(strDatabase)

'Copy database files to new names
FileCopy(strMDFfileName, strMDFfilePath & strNewName & ".mdf")
FileCopy(strLOGfile, strMDFfilePath & strNewName & "_log.ldf")
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5