c# - Restore database timeout? -
i'm trying restore database using following code
string restore = @"restore database [" + dbname+ "] disk = n'" + filepath + "' replace, file = 1, nounload, stats = 10"; sqlcommand restorecmd = new sqlcommand(restore, con); restorecmd.executenonquery();
it returns me timeout expired error, have set connect timeout=300 in connectionstring
but running t-sql script restore database [dbname] disk = n'filepath' replace, file = 1, nounload, stats = 10 works fine
what should fix this?
set commandtimeout property of restorecmd so:
restorecmd.commandtimeout = 300;
Comments
Post a Comment