c# - Error when create Sql job to remove server -


i have problem when add sql job c# code mssql server. if set serverinstance domain name exmaple: "s2n18p9s7" job created done, if use ip server adress "10.1.1.202" connection expection:

microsoft.sqlserver.management.smo.failedoperationexception: apply target server failed job 'job1'.  ---> microsoft.sqlserver.management.common.executionfailureexception: exception occurred while executing transact-sql statement or batch. ---> system.data.sqlclient.sqlexception: specified @server_name ('10.1.1.202') not exist. 

code used created task:

server server = null; microsoft.sqlserver.management.common.serverconnection sc = new microsoft.sqlserver.management.common.serverconnection("10.1.1.202,1433", "removed", "removed"); server = new server(sc); server.loginmode = serverloginmode.normal;  job job = null; jobserver jobserver = server.jobserver; jobschedule schedule = null;  schedule = new jobschedule(jobserver, string.format("task1")); schedule.frequencytypes = frequencytypes.onetime; schedule.activestartdate = datetime.now; schedule.activestarttimeofday = new timespan(20, 0, 0); schedule.create();  job = new job(jobserver, "job1"); job.deletelevel = completionaction.onsuccess; job.create(); job.addsharedschedule(schedule.id); job.applytotargetserver(server.name);  


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -