sql server - Timeout expired. The timeout period elapsed prior to completion of the operation on Azure sql -


i need create 1 sql database on windows azure on global.asax application start event, got error:

timeout expired.  timeout period elapsed prior completion of operation or server not responding.  failure occurred while attempting connect routing destination. duration spent while attempting connect original server - [pre-login] initialization=296; handshake=324; [login] initialization=0; authentication=1; [post-login] complete=94; 

my code follows:

   private void setupssm() {             sqlconnectionstringbuilder connstrbldr = new sqlconnectionstringbuilder             {                 userid = settingshelper.azureusernamedb,                 password = settingshelper.azurepassworddb,                 applicationname = settingshelper.azureapplicationname,                 datasource = settingshelper.azuresqlserver             };              bool created=dbutils.createdatabaseifnotexists(connstrbldr.connectionstring, settingshelper.azureshardmapmgrdb);             if(created)             {                 sharding sharding = new sharding(settingshelper.azuresqlserver, settingshelper.azureshardmapmgrdb, connstrbldr.connectionstring);             }         }      public static bool createdatabaseifnotexists(string connectionstring, string databasename)         {             using (sqlconnection conn = new sqlconnection(connectionstring))             {                 conn.open();                  sqlcommand cmd = new sqlcommand(                     string.format("select * sys.databases [name]=\'{0:s}\'", databasename),                     conn);                  if (cmd.executescalar() == null)                 {                     sqlcommand cmd2 = new sqlcommand(                         string.format("create database [{0:s}];", databasename),                         conn);                      cmd2.executenonquery();                      return true;                 }                 else                     return false;             }         } 

how can increase timeout>? sql timeout or web request timeout due sql not responding?

you can set command timeout doing following, error seeing command timeout, create db taking longer 30 seconds default timeout value.

for example, set timeout 300 seconds cmd.commandtimeout = 300

https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.commandtimeout(v=vs.110).aspx


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -