I have a project and when I try to run it and the data test is big I have always a connection timeout. I added "sqlCmd.CommandTimeout = 3600;" but still not working. What could am I doing wrong?
This is my code:
public void createCode(String ce, int ord, String beh, int wkd)
{
        String strSql = "";
        SqlCommand sqlCmd;
        SqlConnection conexion = new SqlConnection(getConexion());
        try
        {
            if (conexion.State != ConnectionState.Open)
                conexion.Open();
            //The insert works fine in sql server
            strSql = "Insert into x with values"; 
            sqlCmd = new SqlCommand(strSql, conexion);
            sqlCmd.CommandTimeout = 3600;
            sqlCmd.ExecuteScalar();
        }
        catch (Exception ex)
        {               
            throw new Exception("Error creating Code. " + ex.Message);
        }
        finally
        {
            if (conexion.State == ConnectionState.Open)
                conexion.Close();
        }
}
 
     
    