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

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -