How calculate SMO.Transfer progress?
i have work code transfer database using smo.transfer object.
this code start transfer , subscribe event handlers. have such problem: discoveryprogress - does not approach. maybe need use additional options?
m_tr.scriptingerror += new scriptingerroreventhandler(m_tr_scriptingerror);
m_tr.scriptingprogress += new progressreporteventhandler(m_tr_scriptingprogress);
m_tr.discoveryprogress += new progressreporteventhandler(m_tr_discoveryprogress);
m_tr.datatransferevent += new datatransfereventhandler(m_tr_datatransferevent);
m_script = m_tr.scripttransfer();
m_tr.transferdata();
this code start transfer , subscribe event handlers. have such problem: discoveryprogress - does not approach. maybe need use additional options?
m_tr.scriptingerror += new scriptingerroreventhandler(m_tr_scriptingerror);
m_tr.scriptingprogress += new progressreporteventhandler(m_tr_scriptingprogress);
m_tr.discoveryprogress += new progressreporteventhandler(m_tr_discoveryprogress);
m_tr.datatransferevent += new datatransfereventhandler(m_tr_datatransferevent);
m_script = m_tr.scripttransfer();
m_tr.transferdata();
sergey,
you can define event handlers this:
public
static void datatransferhandler(object sender, datatransfereventargs e){
console.writeline(e.datatransfereventtype.tostring() + " : " + e.message);
}
public
static void progresseventhandler(object sender, progressreporteventargs args){
console.write("progress {0} of {1} . . . {2} \n", args.totalcount, args.total, args.current);
}
public
static void scriptingprogresseventhandler(object sender, progressreporteventargs args){
console.write("progress {0} of {1} . . . {2} \n", args.totalcount, args.total, args.current);
}
then set events this:
trans.discoveryprogress +=
new progressreporteventhandler(progresseventhandler);trans.scriptingprogress +=
new progressreporteventhandler(scriptingprogresseventhandler);trans.datatransferevent +=
new datatransfereventhandler(datatransferhandler);by way, don't need call scripttransfer before calling transferdata. scripttransfer returns tsql script in stringcollection, not using.
artur laksberg
sql server team
SQL Server > SQL Server SMO/DMO
Comments
Post a Comment