[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.sqlserver.programming

Export sql-server2k database to ms-acess using sql-dmo

Individuo Desconocido

3/30/2007 10:47:00 AM

Hi all,

I'm trying to get the same functionallity as the "export data" provided by
the enterprise manager using sql-dmo. What I need to do is export an
existing sql-server database into a new ms-access one. I've tried the
following C# code but I don't know how to specify that the destination
database
it has to be an access database. Is there any way to do this?

Thanks for any help.


SQLDMO.Database2 sqldb = new Database2Class();
SQLDMO.SQLServer2 sqlsrv = new SQLServer2Class();
SQLDMO.Transfer2 sqltx = new Transfer2Class();

sqlsrv.Connect(".", "user", "password");
sqldb = (SQLDMO.Database2)sqlsrv.Databases.Item("dnn", "dbo");

sqltx.CopySchema = true;
//sqltx.DestServer = ???????
//sqltx.DestPassword = ???????
//sqltx.DestDatabase = ??????
//sqltx.DestLogin =??????
sqltx.DestUseTrustedConnection = true;
sqltx.CopyAllObjects = true;
sqltx.CopyAllDefaults = true;
sqltx.CopyAllFunctions = true;
sqltx.CopyAllRules = true;
sqltx.CopyAllStoredProcedures = true;
sqltx.CopyAllTables = true;
sqltx.CopyAllTriggers = true;
sqltx.CopyAllUserDefinedDatatypes = true;
sqltx.CopyAllViews = true;

sqltx.CopyData = SQLDMO_COPYDATA_TYPE.SQLDMOCopyData_Replace;
sqltx.DropDestObjectsFirst = true;

sqltx.IncludeDependencies = true;
sqltx.IncludeDB = true;
sqltx.IncludeLogins = true;
sqltx.IncludeUsers = true;
sqltx.ScriptType = SQLDMO_SCRIPT_TYPE.SQLDMOScript_TransferDefault;
sqltx.Script2Type = SQLDMO_SCRIPT2_TYPE.SQLDMOScript2_Default;
sqltx.SourceTranslateChar = false;
sqltx.UseCollation = false;
sqltx.UseDestTransaction = false;

sqldb.Transfer(sqltx);